LitLocalizationController class

A controller class to handle I/O operations required to load and parse the JSON file containing the localized strings.

The loadFromAsset method must be called before localized strings can be displayed on the UI.

loadFromAsset will called twice in general. It will be called first on the initialization of the LitLocalizationServiceDelegate's LitLocalizations object in order to store the JSON parsed values inside the context to be accessible on the UI. The second time it will be called on a FutureBuilder wrapping all UI widgets. Once the parsing has been completed, the localized strings can be displayed on the widget. As long as the parsing is ongoing, a fallback widget should be displayed in order to update the view once the values are able to be read. Otherwise the widget displaying the localized string gets no notification to update itself and therefore no localizations are displayed.

Constructors

LitLocalizationController({bool debug = false})
Creates a LitLocalizationController.
const

Properties

debug bool
States whether to show the debug output.
final
hashCode int
The hash code for this object.
no setterinherited
localizedString Map<String, dynamic>?
Returns the JSON content stored on inside a Map.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

initLocalizations(String jsonAssetURL) Future<void>
Initializes the localizations by starting the I/O fetch.
loadFromAsset(String jsonAssetURL) Future<bool>
Retrieves the content inside the JSON file and initalizes the _localizedStrings object using the retrieved data.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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