setState method

  1. @protected
void setState(
  1. T value, {
  2. bool isLoading = false,
  3. Object? error,
})

Update the state.

Use value to set the new value for this state. Use isLoading to indicate that this state is still busy. Use error to indicate that something is wrong.

Implementation

@protected
void setState(
  T value, {
  bool isLoading = false,
  Object? error,
}) {
  // TODO: Experimental
  if (value == _value && error == _error && isLoading == _isLoading) {
    debugPrint(
        'UPDATE STATE $runtimeType has been ignored, state was equal!\nThis is an experimental feature.');
    return;
  }

  debugPrint('UPDATE STATE $runtimeType:');
  debugPrint('  value:    $_value -> $value');
  debugPrint('  isLoading $_isLoading -> $isLoading');
  debugPrint('  error     $_error -> $error');

  _value = value;
  _isLoading = isLoading;
  _error = error;

  notifyListeners();
}