Translation class

Inheritance

Properties

defaultLocale Locale
getter/setter pair
defaultLocaleOrNull Locale?
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
locale Locale
getter/setter pair
localeOrNull Locale?
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedLocales Iterable<Locale>
getter/setter pair

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

delegate LocalizationsDelegate<Translation>
no setter
i Translation
no setter
languageCode String
no setter
textDirection TextDirection
no setter

Static Methods

changeDefaultLocale(Object? value) → void
changeLocale(Object? value) → void
changeSupportedLocales(Iterable value) → void
get<T extends Object?>({String? key, String? path, String? name, T? defaultValue, T? parser(Object?)?}) → T?
gets<T extends Object?>({String? key, String? path, String? name, List<T>? defaultValue, T? parser(Object?)?}) List<T>
init({bool showLogs = false, Map? initial, String name = kDefaultTranslationName, String defaultPath = kDefaultTranslationPath, Set<String>? paths, Object? defaultLocale, Iterable? supportedLocales, TranslationDelegate? delegate}) Future<void>
localize(String key, {String? name, String? defaultValue, bool applyNumber = false, bool applyRtl = false, String replace(String)?, Map<String, Object?>? args}) String
final inp1 = "There {NUMBER > 1 ? \"are NUMBER items\" : \"is an item\"} in stock"; Translation.localize("key", defaultValue: inp1, args: {'NUMBER': 1}); // There is an item in stock Translation.localize("key", defaultValue: inp1, args: {'NUMBER': 2}); // There are 2 items in stock final inp2 = "Status: {STATUS == active ? \"activated!\" : \"canceled!\"}"; Translation.localize("key", defaultValue: inp2, args: {'STATUS': "active"}); // Status: activated! Translation.localize("key", defaultValue: inp2, args: {'STATUS': "inactive"}); // Status: canceled! final inp3 = "Status: {IS_ACTIVATED ? \"activated!\" : \"inactivated!\"}"; Translation.localize("key", defaultValue: inp3, args: {'IS_ACTIVATED': true}); // Status: activated! Translation.localize("key", defaultValue: inp3, args: {'IS_ACTIVATED': false}); // Status: inactivated! final inp4 = "Last seen: {TIME: {a:now, b:3 min ago}}"; Translation.localize("key", defaultValue: inp4, args: {"TIME": "a"}); // Last seen: now Translation.localize("key", defaultValue: inp4, args: {"TIME": "b"}); // Last seen: 3 min ago
localizes(String key, {String? name, List<String>? defaultValue, bool applyNumber = false, bool applyRtl = false, String replace(String)?, Map<String, Object?>? args}) List<String>
parseLocale(Object? locale) Locale?
parseLocales(Iterable? values) Iterable<Locale>
selectLocale(BuildContext context, [String? reason]) → void
showLocales(BuildContext context, [String? reason]) Future<Locale?>
trNum(String value, {bool applyRtl = false}) String