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

Cod*_*elp 5 android dart flutter

我让他遵循代码

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

我想知道如何将其居中于屏幕的顶部中心。谢谢。

Dar*_*han 7

换行SizedBox并将Container属性设置alignmentAlignment.topCenter。工作代码如下:

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

在此输入图像描述

希望这能回答您的问题。