无法使showDialog的背景透明

问题描述 投票:0回答:1

我正在尝试发出HTTP请求时弹出对话框,为实现此目的,我创建了在屏幕上显示对话框的功能。

这是我的代码。

class AppLoader {
  static Future<void> showLoadingDialog(BuildContext context, GlobalKey key) async {
    return showDialog(
      context: context,
      barrierDismissible: false,
      builder: (ctx) {
        return new WillPopScope(
          onWillPop: () async => false, 
          child: SimpleDialog(
            key: key,
            backgroundColor: Colors.white70,
            children: <Widget>[
              Center( 
                child: Column(children: <Widget>[
                  CircularProgressIndicator(),
                  SizedBox(height: 10),
                  Text('Please wait...', style: TextStyle(color: Colors.black))
                ],),
              )
            ],
          )
        );
      }
    );
  }
}

并按如下方式调用它:

AppLoader.showLoadingDialog(context, _keyLoader);

并且输出是如下屏幕。

enter image description here

如您所见,在中心处显示的是矩形的白色背景形状的框。我要删除白色背景。

我也尝试设置backgroundColor: Colors.transparent,,但它不起作用。它看起来更有线的用户界面。enter image description here

只想显示加载程序和对话框文本。

android flutter dart flutter-layout flutter-dialog
1个回答
0
投票

如果您想将SimpleDialog的背景色更改为透明,然后添加如下所示的高程背景色,

新的SimpleDialog(backgroundColor:Colors.transparent,海拔:0.1,标题:new Text(“您喜欢Flutter吗?”),儿童:[中央(子:列(儿童:[CircularProgressIndicator(),SizedBox(高度:10),Text('Please wait ...',style:TextStyle(color:Colors.black))],),)],);

© www.soinside.com 2019 - 2024. All rights reserved.