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中 也能作用到以路由控制的页面跳转中

 

上一篇:Object-oriented


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