如下直接在 MaterialApp 中使用 Navigator 是会报 Navigator operation requested with a context that does not include a Navigat. ...

Flutter Navigator operation requested with a context that does not include a Navigat

 

修改为如下所示,将要使用路由的部分嵌套一层即可正常使用。

Flutter Navigator operation requested with a context that does not include a Navigat

 

总结:要使用 路由(Navigator),根控件不能直接是 MaterialApp.

解决方法:将 MaterialApp 内容再使用 StatelessWeight 或 StatefulWeight 包裹一层。

相关文章:

  • 2021-11-15
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-09
  • 2022-01-13
  • 2022-12-23
  • 2021-07-05
  • 2022-02-09
相关资源
相似解决方案