gpt4 book ai didi

flutter - 文本未显示在列内第二行 -Flutter

转载 作者:行者123 更新时间:2023-12-03 08:17:56 28 4
gpt4 key购买 nike

我正在努力显示长文本,这是字符串格式的地址。它可能需要一行或两行或多行,我已经尝试了所有解决方案来完全显示文本,但每次它都会溢出。我已经使用了灵活的、可扩展的和所有文本属性,如软包装,但它不起作用。我必须在 ListTile 中显示此列。

showPickedDropoffLocations() {
return Column(
crossAxisAlignment: CrossAxisAlignment
.start, //meant to align elements to the left - seems to be working
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(height: 5),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: const <Widget>[
Icon(
Icons.pin_drop,
color: Colors.pink,
size: 24.0,

),
Text("Pickup Location"),
]),

Container(
height: 50,

child: Text(pickedAddress, style: TextStyle(), softWrap: true)),


Center(
child: Column(
children: [
Text('.'),
Text('.'),
Text('.'),

],
),
),
SizedBox(height: 5),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: const <Widget>[
Icon(
Icons.pin_drop,
color: Colors.green,
size: 24.0,

),
Text("DropOff Location"),
]),

Container(

child: Text(dropOffAddress, style: TextStyle(), softWrap: true)),
],
);
}

当我尝试使用flexible时,会发生此错误

Error 
══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 2343): The following assertion was thrown during performLayout():
I/flutter ( 2343): RenderFlex children have non-zero flex but incoming width constraints are unbounded.
I/flutter ( 2343): When a row is in a parent that does not provide a finite width constraint, for example if it is in a
I/flutter ( 2343): horizontal scrollable, it will try to shrink-wrap its children along the horizontal axis. Setting a
I/flutter ( 2343): flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
I/flutter ( 2343): space in the horizontal direction.
I/flutter ( 2343): These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
I/flutter ( 2343): cannot simultaneously expand to fit its parent.
I/flutter ( 2343): Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
I/flutter ( 2343): children (using Flexible rather than Expanded). This will allow the flexible children to size
I/flutter ( 2343): themselves to less than the infinite remaining space they would otherwise be forced to take, and
I/flutter ( 2343): then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
I/flutter ( 2343): constraints provided by the parent.
I/flutter ( 2343): If this message did not help you determine the problem, consider using debugDumpRenderTree():
I/flutter ( 2343): https://flutter.dev/debugging/#rendering-layer
I/flutter ( 2343): http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html
I/flutter ( 2343): The affected RenderFlex is:
I/flutter ( 2343): RenderFlex#7501a relayoutBoundary=up21 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE(creator:
Row ← Column ← Row ← Container ← Column ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _ListTile ← MediaQuery ← Padding ← SafeArea ← Semantics ← ⋯, parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size), constraints: BoxConstraints(unconstrained), size: MISSING, direction: horizontal, mainAxisAlignment: start, mainAxisSize: max, crossAxisAlignment: center, textDirection: ltr, verticalDirection: down)
I/flutter ( 2343): The creator information is set to:
I/flutter ( 2343): Row ← Column ← Row ← Container ← Column ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _ListTile
I/flutter ( 2343): ← MediaQuery ← Padding ← SafeArea ← Semantics ← ⋯
I/flutter ( 2343): The nearest ancestor providing an unbounded width constraint is: RenderFlex#0f869 relayoutBoundary=up19 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
I/flutter ( 2343): creator: Row ← Container ← Column ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _ListTile ←
I/flutter ( 2343): MediaQuery ← Padding ← SafeArea ← Semantics ← _PointerListener ← Listener ← ⋯
I/flutter ( 2343): parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
I/flutter ( 2343): constraints: BoxConstraints(0.0<=w<=295.4, 0.0<=h<=Infinity)
I/flutter ( 2343): size: MISSING
I/flutter ( 2343): direction: horizontal
I/flutter ( 2343): mainAxisAlignment: start
I/flutter ( 2343): mainAxisSize: max
I/flutter ( 2343): crossAxisAlignment: center
I/flutter ( 2343): textDirection: ltr
I/flutter ( 2343): verticalDirection: down
I/flutter ( 2343): See also: https://flutter.dev/layout/
I/flutter ( 2343): If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
I/flutter ( 2343): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter ( 2343):

最佳答案

您可以使用 Flexible 小部件包装您的 Text 小部件。

Flexible(
child:Text("Your very very long text"),
),

关于flutter - 文本未显示在列内第二行 -Flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68783205/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com