我想将我的对象放在堆栈的右上角。这就是我所拥有的。我知道如果我将 all(LTRB) 设置为 0.0,图像将放置在中心。有没有更简单的方法可以将图像放在右上角?
Widget _buildRemoveIcon()
{
return Positioned(
top:0.0,
left:60.0,
right: 0.0,
bottom:0.0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: new IconButton(
icon: Icon(
Icons.cancel,
color: Colors.red,
),
onPressed: () {
}), //
),
);
}
Run Code Online (Sandbox Code Playgroud)
Sid*_*kar 13
只需从小部件中删除left和bottom参数Positioned即可将小部件与右上角对齐。
例子:
Positioned(
top:0.0,
right: 0.0,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: new IconButton(
icon: Icon(Icons.cancel,color: Colors.red,),
onPressed: () {}),
),
)
Run Code Online (Sandbox Code Playgroud)
您可以使用Align小部件:
Align(
alignment: Alignment.topRight,
child: ...
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8237 次 |
| 最近记录: |