AssetLocalizations class

Localization support using assets files.

Use translate to translate any text.

All translations should be put in the assets/lang/ folder as json files, one for each local (e.g., en.jsonor da.json). Note that only the languageCode of a Locale is used.

Remember to add the assets/lang/ folder to the list of assets in the pubspec.yaml file like this:

flutter:
  assets:
    - assets/lang/
    ...
Implementers

Constructors

AssetLocalizations(Locale locale)
Create an assets localization based on locale.

Properties

filename String
The file name of the localization asset.
no setter
hashCode int
The hash code for this object.
no setterinherited
locale Locale
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
translations Map<String, String>
A map of available translations for this locale.
getter/setter pair

Methods

canTranslate(String key) bool
Can this key be translated by this localization?
load() Future<void>
Load the translations from filename based on the locale.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
translate(String key) String
Translate key to this locale. If key is not translated, key is returned 'as-is'.

Operators

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

Static Methods

of(BuildContext context) AssetLocalizations?
Returns the localized resources object of type AssetLocalizations for the widget tree that corresponds to the given context.