堆栈中的位置控件百分比

问题描述:

假设我想在一个Stack内定位一个控件,但是堆栈位置的百分比而不是固定的大小。如何在扑动中做到这一点?堆栈中的位置控件百分比

我期望Positionned.fromRelativeRect构造函数将是使用0和1之间的浮点数的东西。但似乎不是。

Align允许以百分比定位小部件。但heightFactorwidthFactor更改Align大小而不是子大小。这不是我想要的。

您可以合并Positionned.fillLayoutBuilder以获得此类结果。

new Stack(
    children: <Widget>[ 
     new Positioned.fill(
     child: new LayoutBuilder(
      builder: (context, constaints) { 
      return new Padding(
       padding: new EdgeInsets.only(top: constaints.biggest.height * .59, bottom: constaints.biggest.height * .31), 
       child: new Text("toto", textAlign: TextAlign.center,), 
      ); 
      }, 
     ), 
    ) 
    ], 
),