| j / k | Scroll down / up |
| gg | Scroll to top |
| G | Scroll to bottom |
| ⌘K / / | Open search |
| ? | Show this help |
| Esc | Close search / help |
| n / N | Next / previous section |
| h | Go to landing |
| d | Go to docs |
| : | Command mode — type section name |
Press ? or Esc to close
Connectivity is a single ConnectivityCubit plus a reactive mixin that lets any list auto-reload when the network returns.
Listens to connectivity_plus and exposes isOffline. It keeps a Set of reload listeners and fires them on the offline→online transition only.
class ConnectivityCubit extends Cubit<ConnectivityState> {
final _listeners = <ConnectivityReloadMixin>{};
void register(ConnectivityReloadMixin l) => _listeners.add(l);
void unregister(ConnectivityReloadMixin l) => _listeners.remove(l);
void _onStatusChanged(ConnectivityResult r) {
final offline = r == ConnectivityResult.none;
if (!offline && state.wasOffline) {
for (final l in _listeners) l.onReconnected();
}
emit(state.copyWith(isOffline: offline));
}
} List screens mix in ConnectivityReloadMixin and register themselves. onReconnected refreshes the list.
mixin ConnectivityReloadMixin {
void onReconnected();
}
// In a paginated cubit:
@override
void onReconnected() => refresh(); ConnectivityWrapper slides a banner down from the top whenever isOffline is true. It sits above the shell, below toasts.
BlocBuilder<ConnectivityCubit, ConnectivityState>(
builder: (context, state) => AnimatedSlide(
offset: state.isOffline ? Offset.zero : const Offset(0, -1),
child: const _OfflineBanner(),
),
)