欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Flutter入门疑难杂症:TextField 双击报错:No Media Query widget found._OverlayEntryWidget widgets require a Media

程序员文章站 2022-03-11 18:13:22
...

原因:使用了FlutterEasyLoading,但是没有正确使用导致的。
Flutter入门疑难杂症:TextField 双击报错:No Media Query widget found._OverlayEntryWidget widgets require a Media
正确的使用方法:
Flutter Easy Loading 要包括在Material App内,直接贴代码:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter EasyLoading',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      builder: (BuildContext context, Widget child) {
        return FlutterEasyLoading(
            child: GestureDetector(
          onTap: () {
            FocusScopeNode currentFocus = FocusScope.of(context);
            if (!currentFocus.hasPrimaryFocus) {
              currentFocus.unfocus();
            }
          },
          child: child,
        ));
      },
      home: StartPage(),
    );
  }
}
相关标签: Flutter入门