找不到路线“主页"的生成器.在 _MaterialAppState [英] Could not find a generator for route "home-page" in the _MaterialAppState

查看:24
本文介绍了找不到路线“主页"的生成器.在 _MaterialAppState的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在 Flutter 应用程序中从一个视图导航到另一个视图时出现异常.

I am getting exception when I trying to navigate from one view to another in flutter app.

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');

这篇关于找不到路线“主页"的生成器.在 _MaterialAppState的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆