class PageOne extends StatefulWidget {
@override
_PageOneState createState() => new _PageOneState();
}
class _PageOneState extends State<PageOne> {
// 第一个页面
_getRequests()async{
print('这里进行操作');
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: RaisedButton(onPressed: ()=>
Navigator.of(context).push(new MaterialPageRoute(builder: (_)=>PageTwo()),)
.then((val)=>val?_getRequests():null), // 通过then进行监听回调参数
),
));
}
}
class PageTwo extends StatelessWidget {
// 第二个页面
@override
Widget build(BuildContext context) {
//somewhere
Navigator.pop(context,true); // 第二个就是需要传到参数
}
}
Flutter は前のページに戻り、アクティブに更新をトリガーします
おすすめ
転載: blog.csdn.net/qq_41160739/article/details/124846630
おすすめ
ランキング