executeInitialized<R> method
FutureOr<R>
executeInitialized<R>(
- ExecuteInitializedCallback<
R> callback, { - Initializable? parent,
Executes the callback
ensuring that this instances was fully initialized.
Implementation
FutureOr<R> executeInitialized<R>(ExecuteInitializedCallback<R> callback,
{Initializable? parent}) {
if (isInitialized) {
return callback();
}
var ret = ensureInitialized(parent: parent);
if (ret is Future<InitializationResult>) {
return ret.then((result) {
if (!result.ok) {
throw StateError("Error initializing (async): $this");
}
return callback();
});
} else {
if (!ret.ok) {
throw StateError("Error initializing: $this");
}
return callback();
}
}