gpt4 book ai didi

dart - 将 Widget 定位在 Row 小部件的末尾

转载 作者:IT老高 更新时间:2023-10-28 12:46:04 24 4
gpt4 key购买 nike

我只是被困在这里。我已经尝试了一切,但对我没有任何作用。我想要的只是将 Icon 放在 Row 的右侧。

注意:我尝试将行内的所有小部件设置为 Align 小部件并处理该对齐小部件的位置,但没有任何效果。下面的代码正在检索这个:

enter image description here

这个箭头应该指向 Row 小部件的末尾。这是我的代码:

Row(
mainAxisAlignment: MainAxisAlignment.start, //change here don't //worked
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin:
EdgeInsets.only(left: 8.0, top: 8.0, bottom: 8.0, right: 12.0),
width: 15.0,
height: 15.0,
decoration: BoxDecoration(
color: task.color, borderRadius: BorderRadius.circular(40.0)),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
task.title,
style: TextStyle(
color: Colors.black,
fontSize: 19.0,
fontWeight: FontWeight.bold),
),
Text(
'Duration: ${task.date}',
style: TextStyle(color: Colors.black, fontSize: 14.0),
)
],
),
Icon(Icons.navigate_next, color: Colors.black) // This Icon
],
),

最佳答案

一种解决方案是使用 Spacer 小部件来填充空间

https://docs.flutter.io/flutter/widgets/Spacer-class.html

    Row(
mainAxisAlignment: MainAxisAlignment.start, //change here don't //worked
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
margin:
EdgeInsets.only(left: 8.0, top: 8.0, bottom: 8.0, right: 12.0),
width: 15.0,
height: 15.0,
decoration: BoxDecoration(
color: Colors.red, borderRadius: BorderRadius.circular(40.0)),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"task.title",
style: TextStyle(
color: Colors.black,
fontSize: 19.0,
fontWeight: FontWeight.bold),
),
Text(
'Duration: ${somenum}',
style: TextStyle(color: Colors.black, fontSize: 14.0),
)
],
),
new Spacer(), // I just added one line
Icon(Icons.navigate_next, color: Colors.black) // This Icon
],
),

enter image description here

如果将它添加到行的开头会发生什么。

enter image description here

关于dart - 将 Widget 定位在 Row 小部件的末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52376287/

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