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. ...

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

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

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

原文地址:https://www.cnblogs.com/wf-l5201314/p/10431152.html