LocaleStringTable class

An immutable flat mapping from string key → localized string for one Locale.

Multiple tables may be merged together (LocaleStringTable.merge), e.g. one file per feature area:

final table = LocaleStringTable.merge([uiTable, gameplayTable]);

Constructors

LocaleStringTable({required Locale locale, required Map<String, String> strings})
The table for locale holding strings, keyed by full (dotted) key. The map is kept, not copied: don't change it afterwards.
const
LocaleStringTable.fromMap(Locale locale, Map<String, Object?> map)
Creates a table from a plain Dart Map.
factory
LocaleStringTable.merge(List<LocaleStringTable> tables)
Merges tables into a single table (later entries win on conflict).
factory

Properties

entries → Map<String, String>
Read-only view of all entries.
no setter
hashCode → int
The hash code for this object.
no setterinherited
locale → Locale
The locale this table belongs to.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → int
Number of keys in this table.
no setter

Methods

get(String key) → String?
Returns the string for key, or null if absent.
getOrFallback(String key, String fallback) → String
Returns the string for key, or fallback if absent.
has(String key) → bool
true if key exists in this table.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

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

Static Methods

loadAsset(Locale locale, String assetPath, {AssetBundle? bundle}) → Future<LocaleStringTable>
Loads and parses a JSON asset from assetPath.