首页 > 解决方案 > 在 _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.

标签: dartflutterflutter-layoutdart-2

解决方案


利用

Navigator.push(context, new MaterialPageRoute(
  builder: (context) =>
     new MyHomePage())
  );

代替

Navigator.of(context).pushNamed('/home-page');
//or
Navigator.pushedName(context, '/home-page');

推荐阅读