useDeviceLocale method
Use the device's locale if supported, otherwise default to configured default
Implementation
Future<void> useDeviceLocale() async {
final deviceLocale = WidgetsBinding.instance.platformDispatcher.locale;
// Use the configured locale for the device's language (so `hi_IN`
// becomes the app's `hi`), or the default when it isn't supported.
final config = _getConfig(deviceLocale.languageCode);
await setLocale(config?.locale ?? defaultLocale.locale);
}