应用场景
返回根路由
import 'package:flutter/material.dart';
import 'package:untitled1/pages/Tabs.dart';
class RegisterSecond extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('注册完成'),
),
body: ListView(
children: <Widget>[
SizedBox(height: 200),
RaisedButton(
child: Text('完成',style: TextStyle(
color: Colors.white
),),
onPressed: (){
//返回根路由
Navigator.of(context).pushAndRemoveUntil(
new MaterialPageRoute(builder: (context)=>Tabs()),//Tabs为根路由组件
(route)=>route==null
);
},
color: Theme.of(context).accentColor,
)
],
),
);
}
}
返回上级
onPressed: (){
//返回上级
Navigator.of(context).pop();
},
替换路由
Navigator.of(context).pushReplacementNamed('/RegisterSecond');