您可以从“ initState()”内部调用对话框,以在绘制第一帧后立即保留其外观。
@override void initState() { super.initState(); WidgetsBinding.instance.addPostframeCallback((_) async { await showDialog<String>( context: context, builder: (BuildContext context) => new alertDialog( title: new Text("title"), content: new Text("Message"), actions: <Widget>[ new FlatButton( child: new Text("OK"), onPressed: () { Navigator.of(context).pop(); }, ), ], ), ); }); }


