LocalizationsResolver constructor
- required Iterable<
Locale> supportedLocales, - Locale? locale,
- LocaleListResolutionCallback? localeListResolutionCallback,
- LocaleResolutionCallback? localeResolutionCallback,
- Iterable<
LocalizationsDelegate< ? localizationsDelegates,Object?> >
Creates a LocalizationsResolver that determines the best-fit locale from the set of
supportedLocales
.
If provided, locale resolution will attempt to use locale
as the current locale rather
than the system locale.
Locale resolution behavior can be overridden by providing localeListResolutionCallback
or localeResolutionCallback
.
The delegates set via localizationsDelegates
collectively define all of the localized
resources for a Localizations widget.
See also:
- LocalizationsResolver.localeListResolutionCallback and LocalizationsResolver.localeResolutionCallback for more details on locale resolution behavior.
- LocalizationsDelegate for more details about providing localized resources to a Localizations widget.
Implementation
LocalizationsResolver({
required Iterable<Locale> supportedLocales,
Locale? locale,
LocaleListResolutionCallback? localeListResolutionCallback,
LocaleResolutionCallback? localeResolutionCallback,
Iterable<LocalizationsDelegate<Object?>>? localizationsDelegates,
}) : _locale = locale,
_localeListResolutionCallback = localeListResolutionCallback,
_localeResolutionCallback = localeResolutionCallback,
_localizationsDelegates = localizationsDelegates,
_supportedLocales = supportedLocales {
_resolvedLocale = _resolveLocales(
WidgetsBinding.instance.platformDispatcher.locales,
supportedLocales,
);
WidgetsBinding.instance.addObserver(this);
}