【发布时间】:2021-11-24 18:06:41
【问题描述】:
到目前为止,即使将边距设置为 0 和框约束,它也只是在中间。
Row(children: [
Padding(
padding: const EdgeInsets.fromLTRB(
3, 3, 3, 6),
child: Container(
width: 150,
height: 30,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"Title Sub-title",
textAlign: TextAlign.left,
maxLines: 2,
style: TextStyle(
height: 1.2,
fontFamily:
'Roboto’,
fontSize: 12,
letterSpacing: 0.15,
color: Colors.black,
),
),
),
),
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.fromLTRB(
0, 10, 0, 3),
),
IconButton(
padding: EdgeInsets.zero,
constraints: BoxConstraints(),
onPressed: () {},
icon: Icon(
Icons.bookmark_border,
size: 20.0,
color: Colors.black,
),
),
Text(
"Author",
textAlign: TextAlign.left,
style: TextStyle(
height: 1.1,
fontFamily: 'Roboto Light',
fontSize: 8,
color: Colors.black,
),
),
],
),
],
),
),
),
],
),
【问题讨论】:
-
你应该在行下尝试
crossAxisAlignment:CrossAxisAlignment.start,默认是居中 -
嗨@Jahidul,我试过了,并删除了文本样式下的高度设置。但是图标按钮左侧的填充并没有减少/删除。唯一移动的是“作者”文本行,它变得更高,与书签图标更不对齐。
-
将行包裹在 Padding() 中并从行中移除子 Padding
-
另外,将您的代码以文本形式发布 - 以图像形式发布会使我们难以复制以进行测试和编辑
-
你好@Ranvir,我尝试将代码作为文本发布,但它一直被标记为代码文本过多。 :( 你能看到问题的编辑部分吗?代码在那里。
标签: flutter flutter-layout flutter-dependencies flutter-test