load method

Future<bool> load([
  1. LoaderFunction? actualLoader
])

Does the load process.

  • actualLoader: the function to use in the load process. Will throw a StateError if loader is already set by the constructor.

Implementation

Future<bool> load([LoaderFunction? actualLoader]) async {
  if (_loadFuture != null) return _loadFuture!;

  if (actualLoader != null) {
    if (loader != null) {
      throw StateError(
          "LoadController[$id] already have a LoaderFunction: can't pass another as parameter.");
    }
    loader = actualLoader;
  }

  if (loader == null) {
    throw ArgumentError(
        'LoadController[$id] without LoaderFunction: required as parameter when calling load().');
  }

  _loadFuture = loader!();
  _loadSuccessful = await _loadFuture;

  _loaded = true;

  onLoad.add(this);

  print(this);

  return _loadSuccessful!;
}