diff --git a/CHANGELOG.md b/CHANGELOG.md index eaca510..9c8f4c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -225,4 +225,8 @@ Fix for #150 Initial Flutter 2 support: - intl upgraded to version 0.17.0 - example app upgraded to Android X -- null safe migration \ No newline at end of file +- null safe migration + +## [0.22.1] + +Nullsafe support + static analysis fixes \ No newline at end of file diff --git a/lib/loaders/file_translation_loader.dart b/lib/loaders/file_translation_loader.dart index abd0e8b..f703ffb 100644 --- a/lib/loaders/file_translation_loader.dart +++ b/lib/loaders/file_translation_loader.dart @@ -55,7 +55,7 @@ class FileTranslationLoader extends TranslationLoader implements IFileContent { try { this.locale = locale ?? await findDeviceLocale(); MessagePrinter.info("The current locale is ${this.locale}"); - _decodedMap.addAll(await loadFile(composeFileName()) ?? Map()); + _decodedMap.addAll(await loadFile(composeFileName())); } catch (e) { MessagePrinter.debug('Error loading translation $e'); } @@ -63,8 +63,8 @@ class FileTranslationLoader extends TranslationLoader implements IFileContent { Future _loadFallback() async { try { - final Map? fallbackMap = await loadFile(fallbackFile); - _decodedMap = {...fallbackMap!, ..._decodedMap}; + final Map fallbackMap = await loadFile(fallbackFile); + _decodedMap = {...fallbackMap, ..._decodedMap}; } catch (e) { MessagePrinter.debug('Error loading translation fallback $e'); } @@ -72,10 +72,12 @@ class FileTranslationLoader extends TranslationLoader implements IFileContent { /// Load the fileName using one of the strategies provided @protected - Future loadFile(final String fileName) async { + Future loadFile(final String fileName) async { final List> strategiesFutures = _executeStrategies(fileName); final Stream strategiesStream = Stream.fromFutures(strategiesFutures); - return strategiesStream.firstWhere((map) => map != null); + return await strategiesStream.firstWhere((map) => map != null, + orElse: null) ?? + Map(); } List> _executeStrategies(final String fileName) { diff --git a/pubspec.lock b/pubspec.lock index da0cd85..c25cc9a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -193,7 +193,7 @@ packages: name: xml2json url: "https://pub.dartlang.org" source: hosted - version: "5.0.0-nullsafety.0" + version: "5.0.0" yaml: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 22892ec..f04e036 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_i18n description: i18n made easy for Flutter. With flutter_i18n you can make your app international, using just a simple .json file! -version: 0.22.0 +version: 0.22.1 homepage: https://github.com/ilteoood/flutter_i18n issue_tracker: https://github.com/ilteoood/flutter_i18n/issues