Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure go back button in Browser for Flutter Web App

I'm not asking about webview. This is about Flutter web app. I need to go back to a specific page when user press back button which is inbuilt in browser.

enter image description here

Any guessing ?

I'm getting this error when I press back button

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)
like image 375
Faslur Rajah Avatar asked Apr 20 '20 12:04

Faslur Rajah


People also ask

How do I add back button in Flutter app?

To add custom back button in Flutter AppBar You Just need to Use Leading in AppBar and Use IconButton for leading Just like this. To add custom back button in Flutter AppBar You Just need to Use Leading in AppBar and Use IconButton for leading Just like this.


1 Answers

In case if you don't want to navigate to a new page

    @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()
              ],
            ),
          ),
        ),
      ),
    );
  }
like image 172
Al Mamun Avatar answered Sep 23 '22 01:09

Al Mamun