双击TextFormField [英] double click in TextFormField

查看:164
本文介绍了双击TextFormField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用flutter 1.17.0
,但是当我在TextFormField
中双击双击以将文本粘贴到TextFormField时,出现此错误


。[38; 5;248m════════小部件库
捕获异常39. [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; 244mstate:
_OverlayEntryWidgetState#f2029。[39; 49m。 38; 5; 244m受影响的小部件的所有权链为:
_OverlayEntryWi dget- [LabeledGlobalKey< _OverlayEntryWidgetState>#8f5d7]←_剧院←重叠←方向←FlutterEasyLoading←
EasyLocalizationProvider←ScopedModelDescendant←_InheritedModel←
AnimatedBuilder← $ b

。[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。 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()));
}

类MyApp扩展了StatefulWidget {
@override
State createState(){
return _MyAppState();
}
}

类_MyAppState扩展状态{
final MainModel _model = MainModel();

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

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

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

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

返回ScopedModel< MainModel>(
模型:_model,
子对象:ScopedModelDescendant< MainModel>(
rebuildOnChange:否,
构建器:(BuildContext上下文,小部件子项,MainModel模型){
return EasyLocalizationProvider(
data:data,
子项:FlutterEasyLoading(
子项:MaterialApp(
构建器:(BuildContext上下文,Widget child){
return MediaQuery(
data:MediaQuery.of(context).copyWith(textScaleFactor:1.0),
child:child,
);
},
debugShowCheckedModeBanner:否,
标题:我的应用程序,
localizations代表:[
GlobalCupertinoLocalizations.delegate,
DefaultCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocaliza tions.delegate,
EasylocaLizationDelegate(
locale:Locale('ar','DZ'),path:'assets / languages'),
],
supportLocales:[Locale ('ar','DZ'),Locale('en','US')],
语言环境:data.locale,
主题:ThemeData(
primarySwatch:MySetting.mainColor,
),
主页:SplashScreen(_model),
},
),
),
);
}));
}
}

请提供任何帮助来解决该问题,因为我的应用因解决问题
而停止,红屏错误仍然出现
,我不知道错误在哪里

解决方案

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



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



我希望能对您有所帮助。


i use flutter 1.17.0 but one thing is not good when i tap double click in TextFormField to paste text to TextFormField i get this error

�[38;5;248m════════ Exception caught by widgets library ═══════════════════════════════════�[39;49m �[38;5;244mThe following assertion was thrown building _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#8f5d7](dirty, state: _OverlayEntryWidgetState#f2029):�[39;49m No MediaQuery widget found.

�[38;5;244m_OverlayEntryWidget widgets require a MediaQuery widget ancestor.�[39;49m �[38;5;244mThe specific widget that could not find a MediaQuery ancestor was: _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#8f5d7]�[39;49m �[38;5;244mdirty�[39;49m �[38;5;244mstate: _OverlayEntryWidgetState#f2029�[39;49m �[38;5;244mThe ownership chain for the affected widget is: "_OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#8f5d7] ← _Theatre ← Overlay ← Directionality ← FlutterEasyLoading ← EasyLocalizationProvider ← ScopedModelDescendant ← _InheritedModel ← AnimatedBuilder ← ScopedModel ← ⋯"�[39;49m

�[38;5;248mTypically, the MediaQuery widget is introduced by the MaterialApp or WidgetsApp widget at the top of your application widget tree.�[39;49m

�[38;5;244mThe relevant error-causing widget was�[39;49m �[38;5;248mFlutterEasyLoading�[39;49m �[38;5;244mWhen the exception was thrown, this was the stack�[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

my 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),
            },
          ),
        ),
      );
    }));
}
}

please any help to solve it because my app is stoped for solve this problem and red screen error is still appers and i didn't know where the error

解决方案

I had the same error. In my case, the error was FlutterEasyLoading library.

After remove that library, double click on TextFormField start to work without errors.

I Hope this help you.

这篇关于双击TextFormField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆