技術胖Flutter第四季-19導航父子頁面的跳轉返回html
博客地址:app
https://jspang.com/post/flutter4.html#toc-010less
onPressed是當前按下的時候,按下動做的響應事件jsp
Navigator是導航組件ide
本身寫的代碼沒有問題。就是須要重啓虛擬機 ,從新flutter run 執行如下post
import 'package:flutter/material.dart'; void main(){ runApp(MaterialApp( title:'導航演示01', home: new FirstScreen(), )); } class FirstScreen extends StatelessWidget { @override Widget build(BuildContext context){ return new Scaffold( appBar: AppBar(title:Text('導航頁面')), body: Center( child: RaisedButton( child: Text('查看商品詳情頁'), onPressed: (){ Navigator.push(context, MaterialPageRoute( builder:(context) => new SecondScreen() )); }, ), ), ); } } class SecondScreen extends StatelessWidget { @override Widget build(BuildContext context){ return Scaffold( appBar: AppBar(title: Text('wjw產品詳情頁'),), body: Center( child: RaisedButton( child: Text('返回'), onPressed: (){ Navigator.pop(context); }, ), ), ); } }