【问题标题】:Flutter Web: How to disable backward button of browser in flutter web applicationFlutter Web:如何在 Flutter Web 应用程序中禁用浏览器的后退按钮
【发布时间】:2020-05-02 22:48:01
【问题描述】:

成功登录后,用户重定向到主页,但当用户单击浏览器后退按钮时,它很容易重定向到登录屏幕。我应该怎么做才能禁用向后重定向?

【问题讨论】:

    标签: web flutter


    【解决方案1】:
    class SecondPage extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        /// Hope WillPopScope will do the job for you.
        return WillPopScope(
          onWillPop: () async => null,
          child: Scaffold(
            body: Center(
              child: Text('asd'),
            ),
          ),
        );
      }
    }
    

    【讨论】:

    • 它运行良好,但是当我刷新页面相同的问题时,它重定向到登录屏幕。
    • 登录是我的初始路由。
    • @Olance 您可以查看此pub.dev/packages/universal_html 以帮助存储会话
    猜你喜欢
    • 2021-04-04
    • 2023-01-03
    • 2020-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-01
    • 2011-09-21
    • 2015-09-27
    相关资源
    最近更新 更多