dart - 定位在堆栈内
问题描述
如何正确定位小部件?
我认为定位应该通过一些模板而不是眼睛。
假设我希望白色方块位于黑色容器的顶部中心,一半在黑色容器内部,一半在外部,我该怎么做?
编码:
Positioned(
top: 80,
right: 30,
left: 30,
child: Container(
height: 200,
width: 400.0,
color: Colors.black,
child: Column(
children: <Widget>[],
),
),
),
Positioned(
top: 40,
child: Container(
height: 100.0,
width: 100.0,
color: Colors.white,
),
),
解决方案
你可以这样尝试
Stack(
alignment: Alignment.center,
children: <Widget>[
Positioned(
top: 80,
right: 30,
left: 30,
child: Container(
height: 200,
width: 400.0,
color: Colors.black,
child: Column(
children: <Widget>[],
),
),
),
Positioned(
top: 40,
child: Container(
height: 100.0,
width: 100.0,
color: Colors.white,
),
),
],
)
推荐阅读
- excel - 我的字符串提取代码有修复吗?
- python - Want to split the array element in 10 Chunks based on min and max element in a array
- android - 如何将 onClick 的 androidx-databinding 绑定到带参数的静态方法
- python - Convert folder with .npz file to one .npz
- python - flowgraph exit with error code -11 after start
- python - 熊猫列表和列表之间比较的矢量化
- react-native - How to get data from rxjs?
- java - Hazelcast High Density Memory Store
- visual-studio - How to configure Resharper to decompile the implementation assemblies, not the empty reference assemblies?
- laravel - Laravel 5.8:反序列化():偏移量 0 的 3 个字节出错