listenWhen<TState> method Null safety

Widget listenWhen<TState>(
  1. bool condition(
    1. TState prev,
    2. TState next
    ),
  2. void listener(
    1. BuildContext context,
    2. TCubit cubix
    ),
  3. Widget child,
  4. {Object? family,
  5. bool transient = false}
)

Implementation

Widget listenWhen<TState>(
  bool Function(TState prev, TState next) condition,
  void Function(BuildContext context, TCubit cubix) listener,
  Widget child, {
  Object? family,

  /// remove cubix automatically when the widget is disposed
  bool transient = false,
}) {
  return CubixListener<TCubit>(
    create: this,
    listenWhen: (prev, next) => condition(prev as TState, next as TState),
    listener: listener,
    child: child,
    family: family,
    transient: transient,
  );
}