如何在浏览器中为 Flutter Web App 配置返回按钮

Fas*_*jah 13 web-applications flutter flutter-web

我不是在问 webview。这是关于 Flutter Web 应用程序。当用户按下浏览器内置的后退按钮时,我需要返回特定页面。

在此处输入图片说明

任何猜测?

当我按下后退按钮时出现此错误

Error: Assertion failed: org-dartlang- 
    sdk:///flutter_web_sdk/lib/_engine/engine/history.dart:110:14 
    _userProvidedRouteName != null
    is not true
        at Object.throw_ [as throw] (http://localhost:8300/dart_sdk.js:4770:11)
        at Object.assertFailed (http://localhost:8300/dart_sdk.js:4721:15)
Run Code Online (Sandbox Code Playgroud)

Al *_*mun 10

如果您不想导航到新页面

    @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () async => true,
      child: Scaffold(

        key: _scaffold,
        backgroundColor: Colors.indigo,
        body: Center(
          child: Container(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                registerForm(),
                registerBtn(),
                SizedBox(height: 30,),
                _buildSignInButton()
              ],
            ),
          ),
        ),
      ),
    );
  }
Run Code Online (Sandbox Code Playgroud)


Flo*_*loW 3

onWillPop导航到新页面

class webScope extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new WillPopScope(
      onWillPop: () async => Navigator.push(context, MaterialPageRoute(builder: (context) => new NewPageWidget())),
      child: Scaffold(
        appBar: new AppBar(
          title: new Text("webScope"),
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

6359 次

最近记录:

4 年,2 月 前