devicelocale
v0.8.2A Flutter package that can be used to extract the locales that are currently defined on a device with the current locale set as the first in the list.
Package archive: https://pubdev.letsnova.ru/api/archives/devicelocale/0.8.2.tar.gz
dart pub add devicelocaleReadme
devicelocale
Gets the device locale data, independent of the app locale settings.
Usage
import 'package:devicelocale/devicelocale.dart';
then
List languages = await Devicelocale.preferredLanguages;
String locale = await Devicelocale.currentLocale;
this should return a list of the preferred/current language locales setup on the device, with the current one being the first in the list or just the currently set device locale.
Android specific implementation (no-op on other platforms if supported)
Added per-app language preferences for Android (https://developer.android.com/about/versions/13/features/app-languages#kotlin)
You can check if your current device is supported isLanguagePerAppSettingSupported
And after checking if your device is supported you can set the per-app language preference with setLanguagePerApp(Locale) this will return true if success
Note for Linux
Since GNU/Linux and POSIX doesn't provide a standard API for getting the preferred languages, Devicelocale.preferredLanguages always returns the current locale.
Updates
Sept 2023
merged pull request for compatibility with AGP 8
Feb 2023
Added 2 new functions for this iOS issue
- defaultLocale
- defaultAsLocale
July 2022
Added support for per-app language preferences on Android (https://developer.android.com/about/versions/13/features/app-languages#kotlin) You can now set the per-app language if you have an in app language picker. Updated the demo app
May 2022
Merged pull requests
Oct 2021
Updated the code and APIs used by Flutter for an Android plugin - this was the source of the Deprecated API warning in the Android build.
July 2021
Add beta support for Linux
March 2021
Added test support for web
Updated for null safety
Jul 2020 Locale update v0.3.1
This is an update from a received request, where prior to 0.3.1 the 2 methods:
- preferredLanguages
- currentLocale
returned string values.
There are now 2 equivilent methods
- preferredLanguagesAsLocales
- currentAsLocale
that now also return a Locale object rather than a string.
releases
-
March 2021 1.0.0 Updated to null safety
-
July 2020 0.3.0 Updated Android to support Android Embedding V2
-
Apr 2020 0.2.3 Updated Android code from contributions from @ened
-
Mar 2020 0.2.2 Updated iOS so that if detected locale is null then it is not included in return value
-
Sep 2019 0.2.0 Updated Android following feedback from https://github.com/huzhirento . Fallback to the currentLocale when attempting to get a list of locales fro Android 7 and below as the getLocales() call is a feature of API 24 and failed for Android 7 and below.
Getting Started
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.
Changelog
0.8.2
- 07 Sep 2025 - update android SDK version
0.8.1
- 27 Aug 2024 - Web version bump
0.8.0
- 5 Jul 2024 - Support WASM on web
0.7.1
- 11 Mar 2024 - Merge iOS PrivacyInfo PR
0.7.0
- 19 Sep 2023 - metge PR for AGP 8 compatibility
0.6.0
- 19 Feb 2023 - update for iOS issue, added defaultLocale call
0.5.5
- 30 Aug 2022 - pr to merge macos support
0.5.4
- 6 Jul 2022 - pr merge for lambda not supported issue
0.5.3 - 5 Jul 2022
- merge PR to add additional Android functionality - see readme
0.5.2 - 19 May 2022
- Merge PR to detect token rather than hard code
0.5.1 - 07 May 2022
- Merged PRs for Android and Linux updates
0.5.0 - 03 Oct 2021
- Update Android code to remove deprecation warning
0.4.3 - 15 Sept 2021
- removed debug print statement
0.4.2 - 11 Jul 2021
- beta support for Linux
0.4.1 - 17 Mar 2021
- test support added for web
0.4.0 - 5 Mar 2021
- null safety update
0.3.3 - 20 Oct 2020
- merge update from mono0926 (ios)
0.3.2 - 5 Sep 2020
- merged update from nstrelow (androidx updates)
0.3.1 - 5 Jul 2020
- new methods added to return Locales as well as the original String versions
0.3.0 - 5 Jul 2020
- Added support for Android Embedding V2
0.2.3 - 2 Apr 2020
- updates to Android code
0.2.2 - 14 March 2020
- update iOS so that locale does not show if it is null
0.2.1 - 14 Dec 2019
- enables the plugin to be used in flutter v1.12.13
0.2.0 - 06 Sep 2019
- Updated Android getPreferredLanguages to fallback to the currentLocale if an error occurs when getting getLocales() (below API 24)
0.1.1 - 15 Feb 2019
- Added currentLocale call
0.1.0
- Removed Swift code. Now uses Objective C for iOS implementation
0.0.1
- Initial release.
