How to configure go back button in Browser for Flutter Web App
onWillPop: () {
Navigator.pop(context);
return new Future(() => true);
}
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()
],
),
),
),
),
);
}
onWillPop
Navigate to a new Page
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"),
),
),
);
}
}