第10章路由及导航 -页面跳转基本使用
防采集标记:亢少军老师的课程和资料
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(
title: '导航页面示例',
home: new FirstScreen(),
));
}
class FirstScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('导航页面示例'),
),
body: new Center(
child: new RaisedButton(
child: new Text('查看商品详情页面'),
onPressed: (){
Navigator.push(
context,
new MaterialPageRoute(builder: (context) => new SecondScreen())
);
},
),
),
);
}
}
class SecondScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("导航页面示例"),
),
body: new Center(
child: new RaisedButton(
onPressed: (){
Navigator.pop(context);
},
child: new Text('返回页面'),
),
),
);
}
}
- Flutter技术入门与实战: http://product.dangdang.com/26485813.html
- Flutter交流学习群:894109159
- Flutter开源项目请关注: https://github.com/kangshaojun
- Flutter****:https://edu.****.net/lecturer/2436
@作者: 亢少军