MultiString class

An object that contains string translations for multiple languages. Language keys use two-varter codes like: 'en', 'sp', 'de', 'ru', 'fr', 'pr'. When translation for specified language does not exists it defaults to English ('en'). When English does not exists it falls back to the first defined language.

Example

var values = MultiString.fromTuples([
    'en', 'Hello World!',
    'ru', 'Привет мир!'
]);

var value1 = values.get('ru'); // Result: 'Привет мир!'
var value2 = values.get('pt'); // Result: 'Hello World!'

Constructors

MultiString([dynamic map])
Creates a new MultiString object and initializes it with values.
MultiString.fromJson(Map<String, dynamic> json)
Creates a new MultiString object and initializes it from json values.
factory

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

append(dynamic map) → void
Appends a map with language-translation pairs.
clear() → void
Clears all translations from this MultiString object.
fromJson(Map<String, dynamic> json) → void
Initialize this object from JSON Map object
get(String language) String?
Gets a string translation by specified language. When language is not found it defaults to English ('en'). When English is not found it takes the first value.
getLanguages() List<String>
Gets all languages stored in this MultiString object,
innerValue() → dynamic
Returned inner values in Map object
length() int
Returns the number of translations stored in this MultiString object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(String language, dynamic value) → void
Puts a new translation for the specified language.
remove(String language) → void
Removes translation for the specified language.
toJson() Map<String, dynamic>
Returned JSON Map object from values of this object
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

fromTuples(List tuples) MultiString
Creates a new MultiString object from language-translation pairs (tuples).
fromTuplesArray(List? tuples) MultiString
Creates a new MultiString object from language-translation pairs (tuples) specified as array.
fromValue(dynamic value) MultiString
Creates a new MultiString object from a value that contains language-translation pairs.