【发布时间】:2020-02-02 16:20:01
【问题描述】:
我正在尝试对齐列中的多个行中的文本(一个数字,一个小填充,后跟所述文本),但不知道如何实现它。
我已经尝试了 rows 属性中的每个 MainAxisAlignment 设置。
这个屏幕截图应该能澄清我的问题:左边是模型,它应该是什么样子,右边是颤动的当前状态。 我希望文本与我添加的绿线对齐以可视化我的问题(因此第一个文本需要从右侧开始一点)。
我的代码:
Widget singleStep(BuildContext context, int numToPrint, String text,
{String fineprint = ""}) {
return Padding(
padding: EdgeInsets.only(
bottom: 0.023 * getScreenHeight(context),
left: 0.037 * getScreenWidth(context)),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
RichText(
text: TextSpan(children: <TextSpan>[
TextSpan(
text: "#",
style: GoZeroTextStyles.regular(_NUMBERFONTSIZE,
color: GoZeroColors.green)),
TextSpan(
text: numToPrint.toString(),
style: GoZeroTextStyles.regular(_NUMBERFONTSIZE))
])),
Padding(
padding: EdgeInsets.only(left: 0.017 * getScreenWidth(context)),
child: RichText(
text: TextSpan(
style: GoZeroTextStyles.regular(_TEXTSIZE),
children: <TextSpan>[
TextSpan(text: text + "\n"),
TextSpan(
text: fineprint,
style: GoZeroTextStyles.regular(_FINEPRINTSIZE))
])))
],
));
}
所有步骤都封装在一个列中,该列是 Stack 的子级。
非常感谢您的建议。另外,如果您有任何其他改进代码的建议,请随时发表评论:)
提前谢谢你!
干杯, 大卫
【问题讨论】:
标签: flutter dart alignment flutter-layout