0

I am using getx.

I want to add a delay to the initialRoute of GetMatrialApp.

initialRoute : splash screen

I want to stay on splashscrren for 2-3 seconds and then go to the login screen.

There is no delay even if you put a delay function in the splashscreen's init function.

init function :

  void initState() {
    Timer(Duration(seconds: 3), () async {
      await Navigator.of(context).pushReplacement(
          MaterialPageRoute(builder: (BuildContext context) => loginScreen()));
    });
    super.initState();
  }
lhyojin0821
  • 175
  • 9

2 Answers2

0
  Future.delayed(Duration(seconds: 3), () async {
  await Navigator.of(context).pushReplacement(
      MaterialPageRoute(builder: (BuildContext context) => loginScreen()));
});
Hamza Siddiqui
  • 675
  • 5
  • 12
0

The process of manually entering this time when the program starts is very tedious. I would advise you to use the splashscreen package. enter link description here

Alakba
  • 178
  • 10