proper way to get widget height in SafeArea

后端 未结 4 1950
轮回少年
轮回少年 2021-02-07 02:01

I\'m trying to get the height of widget but it prints the same values

I/flutter (19253): full height: 976.0
I/flutter (19253): safe height: 976.0
         


        
4条回答
  •  鱼传尺愫
    2021-02-07 02:28

    You can always use LayoutBuilder for such cases.

    child: SafeArea(
            child: new LayoutBuilder(
                builder: (BuildContext context, BoxConstraints constraints) {
                  // constraints variable has the size info
                  return Container();
                }
            ),
          ),
    

    for more info: https://www.youtube.com/watch?v=IYDVcriKjsw

提交回复
热议问题