load method

Future<void> load()

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();
    value = await _loadProcess();
    notifyListeners();
    await onDidLoad();
    _loadCompleter?.complete();
    _loadCompleter = null;
  } catch (e) {
    _loadCompleter?.completeError(e);
    _loadCompleter = null;
  } finally {
    _loadCompleter?.complete();
    _loadCompleter = null;
  }
}