localeResolutionCallback property
This callback is responsible for choosing the app's locale when the app is started, and when the user changes the device's locale.
When a localeListResolutionCallback is provided, Flutter will first attempt to
resolve the locale with the provided localeListResolutionCallback. If the
callback or result is null, it will fallback to trying the localeResolutionCallback.
If both localeResolutionCallback and localeListResolutionCallback are left null
or fail to resolve (return null), the WidgetsApp.basicLocaleListResolution
fallback algorithm will be used.
The priority of each available fallback is:
- localeListResolutionCallback is attempted first.
- localeResolutionCallback is attempted second.
- Flutter's
WidgetsApp.basicLocaleListResolution
algorithm is attempted last.
Properly localized projects should provide a more advanced algorithm than
basicLocaleListResolution
as it does not implement a complete algorithm
(such as the one defined in Unicode TR35)
and is optimized for speed at the detriment of some uncommon edge-cases.
This callback considers only the default locale, which is the first locale in the preferred locales list. It is preferred to set localeListResolutionCallback over localeResolutionCallback as it provides the full preferred locales list.
This algorithm should be able to handle a null locale, which indicates Flutter has not yet recieved locale information from the platform.
See also:
- MaterialApp.localeResolutionCallback, which sets the callback of the WidgetsApp it creates.
basicLocaleListResolution
, a static method that implements the locale resolution algorithm that is used when no custom locale resolution algorithm is provided.
Implementation
final LocaleResolutionCallback localeResolutionCallback