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

如下直接在 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 包裹一层。

上一篇:Java Object-Oriented:day11 【 Inner Classes 】


下一篇:VMware Workstation 15 Pro 安装macOS 10.15 Catalina (cdr文件版)