赞
踩
void main() {
runApp(
new MaterialApp(
home: new Screen1(),
routes: <String, WidgetBuilder> {
'/screen1': (BuildContext context) => new Screen1(),
'/screen2' : (BuildContext context) => new Screen2(),
'/screen3' : (BuildContext context) => new Screen3(),
},
)
);
}
Navigator.of(context).pushNamed('routeName');
此种方法只是简单的将我们需要进入的页面push到栈顶,每次都将新建一个新的页面
Navigator.of(context).pushReplacementNamed('/screen1');
指把当前页面在栈中的位置替换成跳转的页面(关闭当前页面,进入下个页面),当新的页面进入后,之前的页面将执行dispose方法。
下面为官方说明:
Replace the current route of the navigator that most tightly encloses the
given context by push
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。