I18nController class

Coordinates locale, bundles, overrides, and translation lookup.

Inheritance
Available extensions

Constructors

I18nController({required I18nConfig config, String? locale, Iterable<I18nBundle> bundles = const []})
Creates an i18n controller with optional in-memory bundles.

Properties

config I18nConfig
Runtime configuration.
final
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
locale String
Current locale code.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addBundle(I18nBundle bundle) → void
Adds or replaces one translation bundle.
addBundles(Iterable<I18nBundle> bundles) → void
Adds or replaces multiple translation bundles.
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
applyOverrideBundle(String source, {required String locale, required String namespace}) I18nBundle

Available on I18nController, provided by the I18nAssetLoading extension

Applies a JSON or ARB payload as runtime overrides for one namespace.
clearOverrides() → void
Clears all runtime translation overrides.
dispose() → void
Discards any resources used by the object.
inherited
loadAssetBundle({required String locale, required String namespace, AssetBundle? assetBundle, String assetPattern = defaultI18nAssetPattern}) Future<I18nBundle>

Available on I18nController, provided by the I18nAssetLoading extension

Loads one ARB asset into this controller.
loadAssetBundles({Iterable<String>? namespaces, Iterable<String>? locales, AssetBundle? assetBundle, String assetPattern = defaultI18nAssetPattern}) Future<List<I18nBundle>>

Available on I18nController, provided by the I18nAssetLoading extension

Loads multiple ARB assets into this controller and notifies once.
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
setLocale(String locale) → void
Changes the current locale and notifies listeners.
setOverride(String key, String? value) → void
Sets or removes one translation override.
setOverrideBundle(I18nBundle bundle) → void
Replaces runtime overrides for one namespace bundle.
setOverrides(Map<String, String> overrides) → void
Replaces all runtime translation overrides.
toString() String
A string representation of this object.
inherited
translate(String key, {String? defaultText, String? fallback, Map<String, Object?> args = const {}}) String
Resolves one translated message.

Operators

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