notify method

  1. @override
bool notify({
  1. SnapState<T>? nextSnap,
  2. SideEffects<T>? sideEffects,
  3. bool shouldOverrideDefaultSideEffects(
    1. SnapState<T>
    )?,
  4. StateInterceptor<T>? stateInterceptor,
})
override

Notify observers

Implementation

@override
bool notify({
  SnapState<T>? nextSnap,
  SideEffects<T>? sideEffects,
  bool Function(SnapState<T>)? shouldOverrideDefaultSideEffects,
  StateInterceptor<T>? stateInterceptor,
}) {
  if (nextSnap != null) {
    final interceptedSnap = interceptState(nextSnap, stateInterceptor);
    if (interceptedSnap?.isWaiting == true || nextSnap.isWaiting) {
      if (!_snapState.isWaiting) {
        completer ??= Completer();
      }
    } else {
      if (_snapState.isWaiting) {
        if (completer?.isCompleted == false) {
          completer!.complete(interceptedSnap?.data ?? nextSnap.data);
          completer = null;
        }
      }
    }

    if (interceptedSnap == null) {
      return false;
    }
    _snapState = interceptedSnap;
  }
  sideEffects
    ?..onSetState?.call(_snapState)
    .._onAfterBuild?.call();
  rebuildState();
  return true;
}