StatefulData<T> constructor

StatefulData<T>({
  1. required Future<T?> loader(),
  2. bool isEmptyValidator(
    1. T? data
    ) = _defaultIsEmptyValidator,
  3. bool startLoading = true,
})

Creates an instance of StatefulData.

A loader function for single data loading must be provided.

If startLoading is 'true', that is default behavior, then data loading is started immediately on creating the object.

Implementation

StatefulData({
  required Future<T?> Function() loader,
  this.isEmptyValidator = _defaultIsEmptyValidator,
  bool startLoading = true,
}) {
  _loader = loader;
  _source = null;
  if (startLoading) {
    loadData();
  }
}