1
votes

As my question says, pressing phone back button application is going back to custom splash screen rather than previous page. Any idea what would be the issue ? Following is main.dart code

void main() => runApp(new MaterialApp(
    theme: ThemeData(primaryColor: Colors.red),
    debugShowCheckedModeBanner: false,
    home: SplashScreen(),
    ))

Splash screen closes after 3 seconds and app goes to login page.

Thanks in advance.

1
Show your SplashScreen page codeA R
after 3 seconds it goes to Login Page @override void initState() { // TODO: implement initState super.initState(); Timer( Duration(seconds: 3), () => Navigator.push( context, MaterialPageRoute( builder: (context) => LoginApp()))); }Tanveer
@AR I had added splashscreen page code.Tanveer
What you want to do exactly, do you want close application directly from the login screen?A R

1 Answers

1
votes

Probably you incorrectly use navigator, use pushReplacement to replace SplashScreen with a new one. and use push to open a new screen on top of the previous.

example:

// Close splash screen and open MainPage
Navigator.of(context).pushReplacement(MainPage.route());

// Open LoginPage on top of the previous page
Navigator.of(context).push(LoginPage.route());