Skip to content

Commit

Permalink
Static type for EasyLocalization.assetLoader (aissat#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyinkin committed Jun 26, 2023
1 parent 2c81ff2 commit 443e1f9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### [4.0.0]

- **BREAKING:** `EasyLocalization.assetLoader` is now `AssetLoader` (was dynamic).

### [3.0.2]

- support intl 18
Expand Down
27 changes: 17 additions & 10 deletions lib/src/easy_localization_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class EasyLocalization extends StatefulWidget {
/// Class loader for localization files.
/// You can use custom loaders from [Easy Localization Loader](https://github.com/aissat/easy_localization_loader) or create your own class.
/// @Default value `const RootBundleAssetLoader()`
// ignore: prefer_typing_uninitialized_variables
final assetLoader;
final AssetLoader assetLoader;

/// Save locale in device storage.
/// @Default value true
Expand Down Expand Up @@ -195,9 +194,12 @@ class _EasyLocalizationProvider extends InheritedWidget {

// _EasyLocalizationDelegate get delegate => parent.delegate;

_EasyLocalizationProvider(this.parent, this._localeState,
{Key? key, required this.delegate})
: currentLocale = _localeState.locale,
_EasyLocalizationProvider(
this.parent,
this._localeState, {
Key? key,
required this.delegate,
}) : currentLocale = _localeState.locale,
super(key: key, child: parent.child) {
EasyLocalization.logger.debug('Init provider');
}
Expand Down Expand Up @@ -245,8 +247,10 @@ class _EasyLocalizationDelegate extends LocalizationsDelegate<Localization> {
/// * use only the lang code to generate i18n file path like en.json or ar.json
// final bool useOnlyLangCode;

_EasyLocalizationDelegate(
{this.localizationController, this.supportedLocales}) {
_EasyLocalizationDelegate({
this.localizationController,
this.supportedLocales,
}) {
EasyLocalization.logger.debug('Init Localization Delegate');
}

Expand All @@ -260,9 +264,12 @@ class _EasyLocalizationDelegate extends LocalizationsDelegate<Localization> {
await localizationController!.loadTranslations();
}

Localization.load(value,
translations: localizationController!.translations,
fallbackTranslations: localizationController!.fallbackTranslations);
Localization.load(
value,
translations: localizationController!.translations,
fallbackTranslations: localizationController!.fallbackTranslations,
);

return Future.value(Localization.instance);
}

Expand Down
21 changes: 8 additions & 13 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
name: easy_localization
description: Easy and Fast internationalizing and localization your Flutter Apps, this package simplify the internationalizing process .
description: Easy and fast internationalizing and localization your Flutter Apps, this package simplifies the internationalizing process.
# author: AISSAT abdelwahab <mr.aissat@gmail.com>
homepage: https://github.com/aissat/easy_localization
issue_tracker: https://github.com/aissat/easy_localization/issues
# publish_to: none

version: 3.0.2
version: 4.0.0-dev

environment:
sdk: '>=2.12.0 <4.0.0'

dependencies:
flutter:
sdk: flutter
shared_preferences: '>=2.0.0 <3.0.0'
intl: '>=0.17.0-0 <=0.18.1'
args: ^2.3.1
path: ^1.8.1
easy_logger: ^0.0.2
flutter_localizations:
sdk: flutter

flutter: { sdk: flutter }
flutter_localizations: { sdk: flutter }
intl: '>=0.17.0-0 <=0.18.1'
path: ^1.8.1
shared_preferences: '>=2.0.0 <3.0.0'

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.1
flutter_test: { sdk: flutter }

0 comments on commit 443e1f9

Please sign in to comment.