Skip to content

Commit

Permalink
0.22.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteoood committed Mar 4, 2021
1 parent 4ea6649 commit 429fa84
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- null safe migration

## [0.22.1]

Nullsafe support + static analysis fixes
12 changes: 7 additions & 5 deletions lib/loaders/file_translation_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,29 @@ 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');
}
}

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');
}
}

/// Load the fileName using one of the strategies provided
@protected
Future<Map?> loadFile(final String fileName) async {
Future<Map> loadFile(final String fileName) async {
final List<Future<Map?>> strategiesFutures = _executeStrategies(fileName);
final Stream<Map?> strategiesStream = Stream.fromFutures(strategiesFutures);
return strategiesStream.firstWhere((map) => map != null);
return await strategiesStream.firstWhere((map) => map != null,
orElse: null) ??
Map();
}

List<Future<Map?>> _executeStrategies(final String fileName) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 429fa84

Please sign in to comment.