Easy_localization: _AssertionError ('dart:ui/window.dart': Failed assertion: line 281: '<optimized out>': is not true.)

Created on 7 Nov 2019  路  12Comments  路  Source: aissat/easy_localization

ELError

Getting this error when phone language is something else except the one defined by us in app.
steps to recreate error :
change phone language to something else than what is defined
Example : defined languages en-US,ar-DZ then set language to French in particular
install app

Most helpful comment

Same error with Flutter 1.9.1+hotfix.6. Updating SharedPreferences not fixed this.

All 12 comments

I am experiencing the same problem, but my device language is correct.

E/flutter ( 5394): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'dart:ui/window.dart': Failed assertion: line 281: '': is not true.
E/flutter ( 5394): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:40:39)
E/flutter ( 5394): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
E/flutter ( 5394): #2 new Locale (dart:ui/window.dart:281:15)
E/flutter ( 5394): #3 _EasyLocalizationState.saveLocale. (package:easy_localization/easy_localization_provider.dart:58:24)
E/flutter ( 5394): #4 State.setState (package:flutter/src/widgets/framework.dart:1141:30)
E/flutter ( 5394): #5 _EasyLocalizationState.saveLocale (package:easy_localization/easy_localization_provider.dart:57:7)
E/flutter ( 5394):
E/flutter ( 5394): #6 _EasyLocalizationState.initState (package:easy_localization/easy_localization_provider.dart:36:5)
E/flutter ( 5394): #7 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4068:58)
E/flutter ( 5394): #8 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3919:5)
E/flutter ( 5394): #9 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3101:14)
E/flutter ( 5394): #10 Element.updateChild (package:flutter/src/widgets/framework.dart:2904:12)
E/flutter ( 5394): #11 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:998:16)
E/flutter ( 5394): #12 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:969:5)
E/flutter ( 5394): #13 RenderObjectToWidgetAdapter.attachToRenderTree. (package:flutter/src/widgets/binding.dart:915:17)
E/flutter ( 5394): #14 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2328:19)
E/flutter ( 5394): #15 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:914:13)
E/flutter ( 5394): #16 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:795:7)
E/flutter ( 5394): #17 runApp (package:flutter/src/widgets/binding.dart:845:7)
E/flutter ( 5394): #18 main (package:bargainer_pro/main.dart:29:3)
E/flutter ( 5394): #19 _runMainZoned.. (dart:ui/hooks.dart:229:25)
E/flutter ( 5394): #20 _rootRun (dart:async/zone.dart:1124:13)
E/flutter ( 5394): #21 _CustomZone.run (dart:async/zone.dart:1021:19)
E/flutter ( 5394): #22 _runZoned (dart:async/zone.dart:1516:10)
E/flutter ( 5394): #23 runZoned (dart:async/zone.dart:1500:12)
E/flutter ( 5394): #24 _runMainZoned. (dart:ui/hooks.dart:221:5)
E/flutter ( 5394): #25 _startIsolate. (dart:isolate-patch/isolate_patch.dart:305:19)
E/flutter ( 5394): #26 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

This problem have something to do with SharedPreferences plug-in. I updated it to the version ^0.5.4+5 and removed the line below from my main.dart file. This solved the problem above.

SharedPreferences.setMockInitialValues({});

Same error with Flutter 1.9.1+hotfix.6. Updating SharedPreferences not fixed this.

Same error on Flutter Channel master, v1.12.3-pre.10

Looks like smth happens during creation of new Locale

image
image

Any updates here? Guys, who faced same problem, can I send my app to prod with this error?

Error is in saveLocale() function... in if statemente :/
Here is fix
image

|| allowed _codeLang to be null and _codeCoun was set to some value.. Replace || with && and i added extra measure _codeLang != '' to fullfill assert in Locale constructor...

image
I Fix it like this. but it is not a best solution if you don't have default lang

Glad to hear about that! Hope the package at pub.dev be updated soon.

@pulstar it's ready
enjoying

I updated here, but it could not find the EasylocaLizationDelegate... I figured out the problem and is the class name, that changed from "EasylocaLizationDelegate" to "EasyLocalizationDelegate"... (notice the uppercase L position). Everything is fine now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

basketball-ico picture basketball-ico  路  6Comments

Melak12 picture Melak12  路  4Comments

Xgamefactory picture Xgamefactory  路  4Comments

fatimahossny picture fatimahossny  路  4Comments

necipk picture necipk  路  5Comments