langswitch 0.1.0
langswitch: ^0.1.0 copied to clipboard
One-command per-app language switching for Flutter: Android 13+ and iOS system language settings, persistence, and a ready-made picker.
0.1.0 #
Initial release.
LangSwitch.init()/LangSwitch.instance— singleton controller,ChangeNotifierandValueListenable<Locale?>.- Persistence via
SharedPreferenceswith keyslangswitch.overrideandlangswitch.nativeAtSet. - Android 13+ integration:
LocaleManager.setApplicationLocales/getApplicationLocalesvia method channeldev.langswitch/native. - iOS integration:
Bundle.main.preferredLocalizationsread-back; opens Settings viaUIApplication.openSettingsURLString. - External OS change detection: compares
getAppLocale()to thenativeAtSetsentinel on resume and locale-change callbacks. The OS wins when they diverge. LangSwitchBuilder—StatelessWidgetwrappingValueListenableBuilder<Locale?>.LanguagePicker— embeddable list widget with endonym labels and selection indicator.showLangSwitchSheet()— bottom sheet on narrow screens,AlertDialogon wide.LanguageNames.nameFor()— native-language-name map for ~65 languages.LocaleResolver— pure BCP-47 resolution (exact → script → country → language → fallback).- CLI
dart run langswitch:setup: auto-detects locales froml10n.yaml/ARBs, writeslocales_config.xml, patchesAndroidManifest.xmlandInfo.plist. Supports--dry-run,--check,--locales,--android-only,--ios-only,--yes. - Example app with
gen_l10n, four locales (en, ur RTL, ar RTL, es), debug panel. - Full unit, widget, and CLI test suite (47 tests).
- Dart-only fallback for Linux, macOS, Windows (no-op platform, in-app switching still works).