flutter_ FlutterEasyLoading导致 双击 TextField时报出错误 No MediaQuery widget found.

不能将 FlutterEasyLoading 用在main MaterialApp外层

报出 No MediaQuery widget found. 的错误在于 查找context并非MaterialApp的context 而是FlutterEasyLoading的context

修改为:

return MaterialApp(
      routes: GyRoutersManager.defaultList,
      theme: GyGlobalTheme.themeLightDefault(),
      onGenerateRoute: GyRoutersManager.onGenerateRoute,
      onUnknownRoute: GyRoutersManager.onUnknowRouter,
      builder: (context, child) {
        return FlutterEasyLoading(child: child);
      },
    );

不用担心, 放在MaterialApp中 builder中 也能作用到以路由控制的页面跳转中

 

posted @ 2020-10-29 09:58  前端法师  阅读(799)  评论(0编辑  收藏  举报