Version: 2.2.1
Platform: Android 10 Simulator
Support locales: en, fr
Stack:
E/flutter (15334): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: NoSuchMethodError: The getter 'languageCode' was called on null.
E/flutter (15334): Receiver: null
E/flutter (15334): Tried calling: languageCode
E/flutter (15334): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
E/flutter (15334): #1 _EasyLocalizationState._checkInitLocale (package:easy_localization/src/easy_localization_app.dart:113:48)
E/flutter (15334): #2 _EasyLocalizationState._init.<anonymous closure> (package:easy_localization/src/easy_localization_app.dart:98:23)
E/flutter (15334): #3 ListMixin.firstWhere (dart:collection/list.dart:144:15)
E/flutter (15334): #4 _EasyLocalizationState._init (package:easy_localization/src/easy_localization_app.dart:97:40)
E/flutter (15334): <asynchronous suspension>
E/flutter (15334): #5 _EasyLocalizationState.initState (package:easy_localization/src/easy_localization_app.dart:71:5)
E/flutter (15334): #6 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
E/flutter (15334): #7 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter (15334): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter (15334): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter (15334): #10 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1028:16)
E/flutter (15334): #11 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:999:5)
E/flutter (15334): #12 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:942:17)
E/flutter (15334): #13 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2412:19)
E/flutter (15334): #14 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:941:13)
E/flutter (15334): #15 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:819:7)
E/flutter (15334): #16 WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:804:7)
E/flutter (15334): #17 _rootRun (dart:async/zone.dart:1122:38)
E/flutter (15334): #18 _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (15334): #19 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
E/flutter (15334): #20 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
E/flutter (15334): #21 _rootRun (dart:async/zone.dart:1126:13)
E/flutter (15334): #22 _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter (15334): #23 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23)
E/flutter (15334): #24 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15)
E/flutter (15334): #25 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19)
E/flutter (15334): #26 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5)
E/flutter (15334): #27 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
If we don't set startLocale, app will meet above issue.
But if set, app will start with startLocale regardless of system locale.
@aissat, @Overman775,
It should set the language of the system when start locale isn't set. It's unreasonable for the application to start with a default language.
Because a global application starts in the language of the person who downloaded the application.
It should set the language of the system when start locale isn't set. It's unreasonable for the application to start with a default language.
Because a global application starts in the language of the person who downloaded the application.
yeah, it's like what u say, start locale it for the case when deves that require setting a default locale
It should set the language of the system when start locale isn't set. It's unreasonable for the application to start with a default language.
Because a global application starts in the language of the person who downloaded the application.yeah, it's like what u say,
start localeit for the case when deves that require setting a default locale
But, If the start locale parameter is null, the default system language should be set. The above error should be corrected.
if we did not set saveLocale=false and without startLocale library crashes above.
but saveLocale=false, app will load system locale.
there are niche exception with above variables.
@zl910627 please send example code for reproduce bug
final locales = [
const Locale('en'),
const Locale('fr'),
];
runApp(EasyLocalization(
child: MyApp(),
saveLocale: false,
supportedLocales: locales,
fallbackLocale: locales[0],
path: 'assets/langs',
));
above code will never crash.
if you comment saveLocale: false, line, you will meet crash
if no saveLocale: false, and set startLocale: locales[0],, then app will not crash
@aissat @zl910627 Bug confirm. Bug only if not set countryCode like in example upper
@zl910627 try easy_localization: 2.2.2-dev
@zl910627 please recheck develop version. Bug fixed?
Let me check today.
Thank you.
thank you for your support!
Most helpful comment
@aissat, @Overman775,
It should set the language of the system when start locale isn't set. It's unreasonable for the application to start with a default language.
Because a global application starts in the language of the person who downloaded the application.