2017-10-08 6 views
0

Stack 안에 위젯을 배치하고 고정 된 크기 대신 스택 위치의 백분율로 배치한다고 가정 해 봅시다. 그것을 어떻게 펄럭 이는가?%로 스택에 위치 위젯

나는 Positionned.fromRelativeRect 생성자가 0과 1 사이의 부동 소수점을 사용하는 것으로 예상 할 수 있습니다. 그러나 아니오처럼 보입니다.

Align 위젯의 위치를 ​​퍼센트로 지정할 수 있습니다. 그러나 heightFactorwidthFactor은 자식 크기 대신 Align 크기를 변경합니다. 그건 내가 원하는 것이 아니야.

답변

1

이러한 결과를 얻으려면 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,), 
      ); 
      }, 
     ), 
    ) 
    ], 
),