假设我想将一个小部件放置在Stack
但使用堆栈位置的百分比而不是固定大小。如何在颤振中做到这一点?
我希望Positionned.fromRelativeRect
构造函数就是这样,使用 0 到 1 之间的浮点数。但似乎不是。
Align
允许以百分比定位小部件。但heightFactor
and widthFactor
改变了Align
尺寸而不是子尺寸。这不是我想要的。
您可以组合一个Positioned.fill
and LayoutBuilder
才能达到这样的结果。
new Stack(
children: <Widget>[
new Positioned.fill(
child: new LayoutBuilder(
builder: (context, constraints) {
return new Padding(
padding: new EdgeInsets.only(top: constraints.biggest.height * .59, bottom: constraints.biggest.height * .31),
child: new Text("toto", textAlign: TextAlign.center,),
);
},
),
)
],
),
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)