verifiedLocale method Null safety

String? verifiedLocale(
  1. String? newLocale,
  2. bool localeExists(
    1. String
  3. {String? onFailure(
    1. String

Given newLocale return a locale that we have data for that is similar to it, if possible.

If newLocale is found directly, return it. If it can't be found, look up based on just the language (e.g. 'en_CA' -> 'en'). Also accepts '-' as a separator and changes it into '_' for lookup, and changes the country to uppercase.

There is a special case that if a locale named "fallback" is present and has been initialized, this will return that name. This can be useful for messages where you don't want to just use the text from the original source code, but wish to have a universal fallback translation.

Note that null is interpreted as meaning the default locale, so if newLocale is null the default locale will be returned.

Can return null only if verification fails and onFailure returns null. Otherwise, throws instead.


static String? verifiedLocale(
        String? newLocale, bool Function(String) localeExists,
        {String? Function(String)? onFailure}) =>
    helpers.verifiedLocale(newLocale, localeExists, onFailure);