Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

flutter -> error to open new route : type 'Future<dynamic>' is not a subtype of type 'Widget'

I have a simple test who open new page after 4000ms from init. But I have this UI error The

following _TypeError was thrown building WithPages(dirty, dependencies: [MediaQuery], state: _WithPages#6c08e):
type 'Future<dynamic>' is not a subtype of type 'Widget'

Here is my code

  @override
  void initState() {

    Future.delayed(const Duration(milliseconds: 4000), () {
      load_first_launch_start();
    });
    super.initState();


  }

  load_first_launch_start() async {

    SharedPreferences prefs = await SharedPreferences.getInstance();
    setState(() {

      first_launch = prefs.getInt('first_launch')??0;
      if(first_launch>=1){
        Navigator.pushAndRemoveUntil(context,   MaterialPageRoute(
          builder: (context) => DrawerPage(),
        ), (e) => false);

      }else{
        
        Navigator.push(
          context,
          MaterialPageRoute(
            builder: (context) => WithPages(),
          ), //MaterialPageRoute
        );
      }
    });

  }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

the error says WithPages() not a widget or doesn’t return widget

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading