addLocale method Null safety
If we do not already have a locale for localeName
then
findLocale
will be called and the result stored as the lookup
mechanism for that locale.
Implementation
void addLocale(String localeName, Function findLocale) {
if (localeExists(localeName)) return;
var canonical = Intl.canonicalizedLocale(localeName);
var newLocale = findLocale(canonical);
if (newLocale != null) {
availableMessages[localeName] = newLocale;
availableMessages[canonical] = newLocale;
// If there was already a failed lookup for [newLocale], null the cache.
if (_lastLocale == newLocale) {
_lastLocale = null;
_lastLookup = null;
}
}
}