ConnectionListener constructor

ConnectionListener(
  1. {Key? key,
  2. ConnectionBloc? bloc,
  3. Widget? child,
  4. ConnectionCallback? onOnline,
  5. ConnectionCallback? onOffline}
)

Implementation

ConnectionListener({
  super.key,
  super.bloc,
  super.child,
  ConnectionCallback? onOnline,
  ConnectionCallback? onOffline,
}) : super(
        listenWhen: (Connection previous, Connection current) =>
            previous != current,
        listener: (BuildContext context, Connection state) {
          return switch (state) {
            Connection.online => onOnline?.call(context),
            Connection.offline => onOffline?.call(context),
          };
        },
      );