SideEffects<T> constructor

SideEffects<T>({
  1. void initState()?,
  2. void dispose()?,
  3. void onSetState(
    1. SnapState<T>
    )?,
  4. VoidCallback? onAfterBuild,
})

Side effect to be called when the state is initialized, mutated and disposed of

See named constructor SideEffects.onData, SideEffects.onError, SideEffects.onWaiting SideEffects.onAll, and SideEffects.onOrElse

Implementation

SideEffects({
  this.initState,
  this.dispose,
  this.onSetState,
  VoidCallback? onAfterBuild,
}) {
  if (onAfterBuild != null) {
    _onAfterBuild =
        ([bool? isDisposed]) => WidgetsBinding.instance.addPostFrameCallback(
              (_) {
                if (isDisposed != true) {
                  onAfterBuild();
                }
              },
            );
  }
}