Created
October 2, 2022 21:31
-
-
Save bartekpacia/a0bd6cfee4271f501b2f36a41ff2ac79 to your computer and use it in GitHub Desktop.
Useful localization-related extensions in Flutter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension BuildContextLocalizations on BuildContext { | |
Locale get locale => Localizations.localeOf(this); | |
String get languageCode => locale.toLanguageTag(); | |
AppLocalizations get l10n => AppLocalizations.of(this)!; | |
List<Locale> get supportedLocales => AppLocalizations.supportedLocales; | |
List<Locale> get realSupportedLocales => AppLocalizationsX.supportedLocales; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment