0

我有以下功能来显示一个对话框,我使用媒体查询将其设置为 100%,但是当它运行时,我仍然看到对话框周围的白边。

如何归档全屏对话框?

Future<void> showLoadingDialog(BuildContext context, GlobalKey key) async {

    Widget myDialog = SimpleDialog(
        key: key,
        backgroundColor: Colors.black54,
        children: <Widget>[
          Container(
            width: MediaQuery.of(context).size.width,
            child: Column(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  CircularProgressIndicator(),
                  SizedBox(height: 10,),
                  Text("Please Wait....",style: TextStyle(color: accentColor),)
                ]),
          )
        ]);

    return showDialog<void>(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) {
          return myDialog;
        });
  }
4

1 回答 1

1

您可以使用showGeneralDialog小部件来完成。

showGeneralDialog(
        context: context,
        barrierDismissible: true,
        barrierLabel:
            MaterialLocalizations.of(context).modalBarrierDismissLabel,
        barrierColor: Colors.black45,
        transitionDuration: const Duration(milliseconds: 200),
        pageBuilder: (BuildContext buildContext, Animation animation,
            Animation secondaryAnimation) {
          return Center(
            child: Container(
              width: MediaQuery.of(context).size.width - 10,
              height: MediaQuery.of(context).size.height - 80,
              padding: EdgeInsets.all(20),
              color: Colors.white,
              child: Column(
                children: [
                  RaisedButton(
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                    child: Text(
                      "Save",
                      style: TextStyle(color: Colors.white),
                    ),
                    color: const Color(0xFF1BC0C5),
                  )
                ],
              ),
            ),
          );
        });
于 2020-04-30T04:27:09.990 回答