为什么应用程序在后退按钮上关闭-Flutter

时间:2020-01-22 13:03:03

标签: android flutter dart flutter-navigation

正如我的问题所述,按下电话后退按钮应用程序将返回自定义启动屏幕,而不是上一页。知道会有什么问题吗?以下是main.dart代码

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

启动屏幕3秒后关闭,应用程序进入登录页面。

谢谢。

1 个答案:

答案 0 :(得分:1)

可能您不正确地使用了导航器,使用pushReplacementSplashScreen替换为新的导航器。并使用push打开上一个屏幕。

示例:

// 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());