gpt4 book ai didi

Flutter 行文本溢出

转载 作者:行者123 更新时间:2023-12-05 04:45:27 25 4
gpt4 key购买 nike

我无法正确布局它。

我正在努力实现

Attached an image to explain what I'm trying to achieve

这是我迄今为止尝试过的最接近它但并不完全正确的方法。

  Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Flexible(
child: Row(children: [
PrefixIcon(),
Flexible(
child: DefaultTextStyle(
overflow: TextOverflow.ellipsis,
child: TextGoesHere(),
),
),
SuffixIcon(),
]),
),
TrailingIcon(),
]),

但是 FlexibleFlexFit.loose 的行为类似于 Expanded 所以 SuffixIcon 被推到最后,即使TextGoesHere 是一个短文本。

我到目前为止

I got so far

请帮忙。

最佳答案

如果您考虑 .. 来自 TextOverflow.ellipsis,到目前为止我已经了解了行。

color container just for visual

enter image description here

小工具

 Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Prefix"),
Expanded(
child: Container(
color: Colors.deepOrange,
child: Row(
children: [
Flexible(
child: Text(
"Very LongggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggText",
maxLines: 1,
),
),
Icon(
Icons.tag_sharp,
)
],
),
),
),
Text("TrailingIcon"),
],
),

否则,如果我们知道前缀和图标大小,我们可以使用 LayoutBuilder

关于Flutter 行文本溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69115858/

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