简体   繁体   English

Flutter/Dart 如何将 sizedbox 居中到屏幕的顶部中心?

[英]Flutter/Dart How to center sizedbox to top center of screen?

I have he following code我有他下面的代码

return SizedBox(
                        child: CircularProgressIndicator(valueColor: new AlwaysStoppedAnimation<Color>(Colors.pink)),
                        height: 20.0,
                        width: 20.0,
                      );

I would like to know how to center this to the top center of the screen.我想知道如何将其居中到屏幕的顶部中心。 Thank you.谢谢你。

Wrap SizedBox with Container and set alignment property to Alignment.topCenter .Container包裹SizedBox并将alignment属性设置为Alignment.topCenter Working code below:工作代码如下:

body: Container(
        alignment: Alignment.topCenter,
      child: SizedBox(
                        child: CircularProgressIndicator(valueColor: new AlwaysStoppedAnimation<Color>(Colors.pink)),
                        height: 20.0,
                        width: 20.0,
                      )),

在此处输入图片说明

Hope this answers your question.希望这能回答你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM