Flutter showDialog(context) in initState method

后端 未结 4 1320
北海茫月
北海茫月 2021-01-05 08:25

I\'m trying to use the showDialog(context, builder) to display a greeting message when the user navigates to a certain page.

I tried this by calling the

4条回答
  •  情深已故
    2021-01-05 08:58

    @override
      void initState() {
        super.initState();
        WidgetsBinding.instance.addPostFrameCallback((_) async {
          await showDialog(
            context: context,
            builder: (BuildContext context) => new showDialog(
               context: context, 
               builder: (BuildContext context) {
                  return new Container(child: new Text('foo'));
              });
          );
        });
      }
    

提交回复
热议问题