Flutter 利用 Navigator.of(context).pop(this) 黑屏问题

当直接调用跳转的时候会遇到红屏报错的问题

Navigator.of(context).push(
                MaterialPageRoute(builder: (context) {
                 return JumpPage();//返回的是需要跳转单页面
                },));

此时不要保存热更新,需要重新运行项目即可

另外,当退出当前页面使用pop方法返回上一级的时候,会出现黑屏的现象

Navigator.of(context).pop(this);

主要是因为MaterialApp()的问题,只有main.dart设置MaterialApp就好,其他页面不需要设置MaterialApp,直接返回Scaffold即可

class RowDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text("动态GridView")), body: BodyContent());
  }
}

此时就可以正常使用pop方法退出此页面了