devicelocale
현재 장치에 정의된 로케일을 추출하는 데 사용할 수 있는 Flutter 패키지로, 현재 로케일이 목록의 첫 번째로 설정됩니다.
설정된 디바이스 로케일을 읽고 반환하는 Flutter 패키지
{"sdk":"flutter"}{"sdk":"flutter"}^1.0.0{"sdk":"flutter"}아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
Gets the device locale data, independent of the app locale settings.
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.
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
Since GNU/Linux and POSIX doesn't provide a standard API for getting the preferred languages, Devicelocale.preferredLanguages always returns the current locale.
Both CocoaPods and Swift Package Manager are supported; Flutter ≥ 3.44 uses SwiftPM automatically. To verify SwiftPM locally on Xcode 26+, clone the repository into a directory matching the pubspec name, otherwise the example app build fails with a SwiftPM identity-mismatch error (pub.dev users are unaffected):
git clone https://github.com/magnatronus/flutter-devicelocale.git devicelocale
merged pull request for compatibility with AGP 8
Added 2 new functions for this iOS issue
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
Merged pull requests
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.
Add beta support for Linux
Added test support for web
Updated for null safety
This is an update from a received request, where prior to 0.3.1 the 2 methods:
returned string values.
There are now 2 equivilent methods
that now also return a Locale object rather than a string.
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.
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.