双击TextFormField

时间:2020-05-31 12:53:38

标签: flutter dart

我用flutter 1.17.0 但是当我在TextFormField中双击时一件事情不好 粘贴文本到TextFormField我得到这个错误

。[38; 5;248m════════小部件库捕获到异常 ═══════════════════════════════════�[39; 49m�[38; 5; 244m 断言被抛出 _OverlayEntryWidget- [LabeledGlobalKey <_OverlayEntryWidgetState>#8f5d7](脏, 状态:_OverlayEntryWidgetState#f2029):[[39; 49m没有MediaQuery小部件 找到。

。[38; 5; 244m_OverlayEntryWidget小部件需要MediaQuery小部件 祖先。[39; 49m [[38; 5; 244m]无法找到 MediaQuery的祖先是: _OverlayEntryWidget- [LabeledGlobalKey <_OverlayEntryWidgetState>#8f5d7]。[39; 49m ``[38; 5; 244mdirty。[39; 49m [[38; 5; 244m _OverlayEntryWidgetState#f2029。[39; 49m [[38; 5; 244m] “ _OverlayEntryWidget- [LabeledGlobalKey <_OverlayEntryWidgetState>#8f5d7]←_剧院←重叠←方向性←FlutterEasyLoading← EasyLocalizationProvider←ScopedModelDescendant←_InheritedModel← AnimatedBuilder←ScopedModel←⋯“。[39; 49m

。[38; 5; 248m通常,MediaQuery小部件由 应用程序小部件顶部的MaterialApp或WidgetsApp小部件 树。。[39; 49m

。[38; 5; 244m相关的引起错误的小部件为。''[39; 49m [38; 5; 248mFlutterEasyLoading。[39; 49m。[38; 5; 244m 被抛出,这是堆栈。[39; 49m [[38; 5; 244m#0 debugCheckHasMediaQuery .. [39; 49m [[38; 5; 244m#1 debugCheckHasMediaQuery。[39; 49m [[38; 5; 244m#2 _MaterialTextSelectionControls.buildToolbar。[39; 49m [[38; 5; 244m#3 TextSelectionOverlay._buildToolbar。[39; 49m [[38; 5; 244m#4 _OverlayEntryWidgetState.build。[39; 49m [[38; 5; 244m ...] [39; 49m [[38; 5;248m════════════════════ ══════════════════════════════════════════════════ ══════════�[39; 49m

我的main.dart

void main() {
runApp(EasyLocalization(child: MyApp()));
}

class MyApp extends StatefulWidget {
@override
State createState() {
return _MyAppState();
}
}

class _MyAppState extends State {
final MainModel _model = MainModel();

@override
void initState() {
SystemChrome.setPreferredOrientations([

]);
_model.initAppDirectory();
super.initState();
}

changeStatusBar() async{
await FlutterStatusbarcolor.setStatusBarColor(MySetting.mainColor);
FlutterStatusbarcolor.setStatusBarWhiteForeground(true);
if(Theme.of(context).platform == TargetPlatform.android){
await FlutterStatusbarcolor.setNavigationBarColor(Colors.black38);
}
}

@override
Widget build(BuildContext context) {
changeStatusBar();
var data = EasyLocalizationProvider.of(context).data;

return ScopedModel<MainModel>(
    model: _model,
    child: ScopedModelDescendant<MainModel>(
      rebuildOnChange: false,
        builder: (BuildContext context, Widget child, MainModel model) {
      return EasyLocalizationProvider(
        data: data,
        child: FlutterEasyLoading(
          child: MaterialApp(
            builder: (BuildContext context, Widget child) {
              return MediaQuery(
              data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
              child: child,
              );
            },
            debugShowCheckedModeBanner: false,
            title: 'my app',              
            localizationsDelegates: [
              GlobalCupertinoLocalizations.delegate,
              DefaultCupertinoLocalizations.delegate,
              GlobalMaterialLocalizations.delegate,
              GlobalWidgetsLocalizations.delegate,
              EasylocaLizationDelegate(
                  locale: Locale('ar', 'DZ'), path: 'assets/languages'),
            ],
            supportedLocales: [Locale('ar', 'DZ'), Locale('en', 'US')],
            locale: data.locale,
            theme: ThemeData(
              primarySwatch: MySetting.mainColor,
            ),
            home: SplashScreen( _model),
            },
          ),
        ),
      );
    }));
}
}

请解决任何问题 因为我的应用已停止解决此问题 和红屏错误仍然出现 而且我不知道错误在哪里

1 个答案:

答案 0 :(得分:0)

我有同样的错误。就我而言,错误是FlutterEasyLoading库。

删除该库后,双击TextFormField即可开始正常运行。

希望对您有帮助。