basedOnSystem property
Localization?
basedOnSystem
Returns the best option based on the system's language(s).
Throwns an AssertionError
if localizations
is empty
Implementation
static Localization? get basedOnSystem {
assert(
localizations.isNotEmpty,
'You must set the localizations before using them',
);
final preferredLocale =
window.computePlatformResolvedLocale(localizations.toLocaleList());
if (preferredLocale != null) return getByLocale(preferredLocale);
final List<Locale> systemLocales = Localization.systemLocales;
for (final locale in systemLocales) {
final loc = getByLocale(locale);
if (loc != null) return loc;
}
return localizations.first;
}