dart - 在 _MaterialAppState 中找不到路由“主页”的生成器
问题描述
当我尝试在颤振应用程序中从一个视图导航到另一个视图时,我遇到了异常。
I/flutter ( 2199): ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
I/flutter ( 2199): The following assertion was thrown while handling a gesture:
I/flutter ( 2199): Could not find a generator for route "home-page" in the _MaterialAppState.
解决方案
利用
Navigator.push(context, new MaterialPageRoute(
builder: (context) =>
new MyHomePage())
);
代替
Navigator.of(context).pushNamed('/home-page');
//or
Navigator.pushedName(context, '/home-page');
推荐阅读
- node.js - Nodejs,http post json
- go - 有没有办法确定使用 `flag.VisitAll` 时是否设置了标志?
- javascript - Ace 编辑器添加自定义 JS API
- foursquare - Foursquare 场地数据过时?
- xaml - 新的 OnPlatform/OnIdiom XAML 扩展 - 用于边距厚度
- android - 为什么内部 AsyncTask 需要是静态的,而 Thread 不需要?
- python - Python:使用 cron 将数据写入 txt 文件
- c++ - 如何在c ++中迭代数组中的唯一元素
- json - 按管道过滤:模板解析错误 Angular4
- django - 确保 Django 中的字段始终为空