@@ -944,6 +944,46 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
944
944
buildOwner.reassemble (renderViewElement);
945
945
return super .performReassemble ();
946
946
}
947
+
948
+ /// Computes the locale the current platform would resolve to.
949
+ ///
950
+ /// This method is meant to be used as part of a [localeListResolutionCallback] .
951
+ /// Since this method may return null, a Flutter/dart algorithm should still be
952
+ /// provided as a fallback in case a native resolved locale cannot be determined
953
+ /// or if the native resolved locale is undesirable.
954
+ ///
955
+ /// This method may return a null [Locale] if the platform does not support
956
+ /// native locale resolution, or if the resolution failed.
957
+ ///
958
+ /// The first [supportedLocale] is treated as the default locale and will be returned
959
+ /// if no better match is found.
960
+ ///
961
+ /// Android and iOS are currently supported.
962
+ ///
963
+ /// On Android, the algorithm described in
964
+ /// https://developer.android.com/guide/topics/resources/multilingual-support
965
+ /// is used to determine the resolved locale. Depending on the android version
966
+ /// of the device, either the modern (>= API 24) or legacy (< API 24) algorithm
967
+ /// will be used.
968
+ ///
969
+ /// On iOS, the result of `preferredLocalizationsFromArray` method of `NSBundle`
970
+ /// is returned. See:
971
+ /// https://developer.apple.com/documentation/foundation/nsbundle/1417249-preferredlocalizationsfromarray?language=objc
972
+ /// for details on the used method.
973
+ ///
974
+ /// iOS treats script code as necessary for a match, so a user preferred locale of
975
+ /// `zh_Hans_CN` will not resolve to a supported locale of `zh_CN` .
976
+ ///
977
+ /// Since implementation may vary by platform and has potential to be heavy,
978
+ /// it is recommended to cache the results of this method if the value is
979
+ /// used multiple times.
980
+ ///
981
+ /// Second-best (and n-best) matching locales should be obtained by calling this
982
+ /// method again with the matched locale of the first call omitted from
983
+ /// [supportedLocales] .
984
+ Locale computePlatformResolvedLocale (List <Locale > supportedLocales) {
985
+ return window.computePlatformResolvedLocale (supportedLocales);
986
+ }
947
987
}
948
988
949
989
/// Inflate the given widget and attach it to the screen.
0 commit comments