gpt4 book ai didi

flutter - 如何在Flutter中将2行文本与1行文本对齐

转载 作者:行者123 更新时间:2023-12-03 03:33:19 26 4
gpt4 key购买 nike

因此,我希望包含2行字符串的行(“这里有2行很长的字符串”)与1行字符串正确对齐:(“名称:”),但是我想这样做而不检查字符串长度。
这是我的代码行:

Row(
children: <Widget>[
Text(
title,
style: Theme.of(context).textTheme.headline6.copyWith(height: 1.24),
),
Spacer(),
Container(
width: 242.0,
alignment: Alignment.bottomRight,
child: Text(
text,
textAlign: TextAlign.end,
maxLines: 2,
style: Theme.of(context).textTheme.bodyText1.apply(
color: kGrey,
),
),
),
],
);
至于我想要的结果,这是一个图像示例:
enter image description here

最佳答案

使用crossAxisAlignment Row参数将文本对齐以开始crossAxisAlignment: CrossAxisAlignment.start解-

       Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
title,
style: Theme.of(context)
.textTheme
.headline6
.copyWith(height: 1.24),
),
Spacer(),
Container(
width: 242.0,
alignment: Alignment.bottomRight,
child: Text(
text,
textAlign: TextAlign.end,
maxLines: 2,
style: Theme.of(context).textTheme.bodyText1.apply(
color: kGrey,
),
),
),
],
),
希望这会对您有所帮助。如果您有任何疑问,请在评论中提出。

关于flutter - 如何在Flutter中将2行文本与1行文本对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62515993/

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