Вы можете отобразить всплывающее диалоговое окно, используя showDialog
.
static Future showDialog(BuildContext context, GlobalKey _key) async {
return showLoadingDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context){
return SimpleDialog(
key: _key,
children: <Widget>[
Center(
child: Container(
child: Row(
children: <Widget>[
CircularProgressIndicator(),
SizedBox(
height:10,
width:10,
),
Text("Please Wait!"),
]
),
],
),
);
}
);
}
Здесь GlobalKey
используется для Show
или hide
созданного диалогового окна.
Для вызова этого просто инициализировать GlobalKey
в классе как GlobalKey<State> _dialogKey = GlobalKey<State>();
.
Затем вы можете отобразить диалог как:
showLoadingDialog(context, _dialogKey);
И когда вы хотите, чтобы он скрылся, просто позвоните:
Navigator.of(_dialogKey.currentContext,rootNavigator: true).pop();
Надеюсь, это поможет.