nav

代码:

import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: '导航演示',
home: new FirstScreen()

));
}

class FirstScreen extends StatelessWidget{
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(title: Text('首页'),),
body: Center(
child: RaisedButton(
child: Text('进入详情页'),
onPressed: (){
Navigator.push(context, MaterialPageRoute(
builder: (context) => new SecondScreen()
));
},
),
),
);
}
}

class SecondScreen extends StatelessWidget{
Widget build (BuildContext context){
return Scaffold(
appBar: AppBar(title: Text('详情页'),),
body: Center(
child: RaisedButton(
child: Text('返回首页'),
onPressed: (){
Navigator.pop(context);
},
),
),
);
}

}
 
总结:

 

//nav 导航

//压栈

 

路由传递

Navigator.push (context,MateriapageRoute(

builder:(context) => new xxxx()//xxx 是要进入的新页面

 

))

出栈

Navigator.pop(context)//返回上一级

原文地址:https://www.cnblogs.com/pp-pping/p/12165469.html