flutter navigation pushreplacement
void _completeLogin() {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (BuildContext context) => MyHomePage()));
}
flutter navigation pushreplacement
void _completeLogin() {
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (BuildContext context) => MyHomePage()));
}
Navigator.pushReplacementNamed parameters
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(),
routes: <String, WidgetBuilder> {
'/form': (BuildContext context) => new FormPage(), //new
},
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
floatingActionButton: new FloatingActionButton(
onPressed: () {
Navigator.of(context).pushReplacement( //new
new MaterialPageRoute( //new
settings: const RouteSettings(name: '/form'), //new
builder: (context) => new FormPage(email: '[email protected]', header: {'auth': '1234'}) //new
) //new
); //new
},
child: new Icon(Icons.navigate_next),
),
);
}
}
class FormPage extends StatefulWidget {
FormPage({Key key, this.email, this.header}) : super(key: key);
String email;
Map header;
@override
FormPageState createState() => new FormPageState();
}
class FormPageState extends State<FormPage> {
@override
Widget build(BuildContext context) {
return new Container(
child: new Column(
children: <Widget>[
new Text(widget.email),
new Text(widget.header['auth'])
],
),
);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us