load method
Retrieves data and updates the data in the model.
You will be notified of model updates at the time they are retrieved.
In addition,
the updated Resuult
can be obtained at the stage where the loading is finished.
Implementation
Future<void> load() async {
if (_loadCompleter != null) {
return loading;
}
_loadCompleter = Completer<void>();
try {
await onLoad();
await loadRequest();
notifyListeners();
await onDidLoad();
_loadCompleter?.complete();
_loadCompleter = null;
} catch (e) {
_loadCompleter?.completeError(e);
_loadCompleter = null;
rethrow;
} finally {
_loadCompleter?.complete();
_loadCompleter = null;
}
}