初始化路由文章来源:https://www.toymoban.com/news/detail-609336.html
MaterialApp( routes: <String, WidgetBuilder>{ "/Second": (BuildContext context){ return Second(""); } },
跳转传参数文章来源地址https://www.toymoban.com/news/detail-609336.html
String va = await Navigator.of(context).push(MaterialPageRoute( builder: (content) { return Second( 'demo'); }, )); print('回掉=====$va');
class Second extends StatelessWidget { final String str; const Second(this.str, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { return ElevatedButton( onPressed: () { Navigator.of(context).pop("asdadad"); }, child: Text("第二个${str}"), ); } }
到了这里,关于Flutter中Navigator 跳转传参数和反向传参数的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!