AppLocale class

The AppLocale class manages the localization functionality for the application, handling the loading of language files, providing translation strings, and offering support for multiple locales.

Constructors

AppLocale.new(Locale currentLocale)
A class that manages localization in the application, handling language loading, localization delegates, and supported locales.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getTranslated(String key) String?
This asynchronous method retrieves the translation for the provided key from the loaded localization values. It first ensures that the AppLocale instance is properly loaded within the current context. If the key exists in the loaded localization values, the corresponding translation is returned. If the key is not found, null is returned
loadLanguage(Locale locale) Future
Loads the language JSON file corresponding to the provided locale. The key-value pairs from the JSON file are stored in _loadedLocalizedValue Locale locale: The locale whose language file should be loaded.
localeResolutionCallback(Locale? currentLocale, Iterable<Locale> supportedLocales) Locale?
Determines the best match for the current locale from the list of supported locales. If no match is found, the first supported locale is returned. Locale? currentLocale: The current locale of the device. Iterable<Locale> supportedLocales: A list of locales supported by the application.
localizationsDelegates() Iterable<LocalizationsDelegate>?
Returns a list of localization delegates required by the application, including material, widget, and Cupertino localizations, along with the custom AppLocale delegate.
supportedLocale() List<Locale>
Returns a list of locales supported by the application. This list is assumed to be defined elsewhere in the class (e.g., _supportedLocale).

Constants

delegate → const LocalizationsDelegate<AppLocale>
The delegate property is a static constant of type LocalizationsDelegate<AppLocale>. It provides a way to load the localized resources for the AppLocale class, which is essential for managing internationalization in a Flutter app.