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) {
          switch (state) {
            case Connection.online:
              return onOnline?.call(context);
            case Connection.offline:
              return onOffline?.call(context);
          }
        },
      );