fconnectivity 0.0.1
fconnectivity: ^0.0.1 copied to clipboard
Connectivity package that contains useful utilities for checking if device is connected to the internet.
fconnectivity #
A Flutter package that provides utilities for checking internet connectivity status. It allows developers to easily manage and respond to changes in internet access state within their applications.
Usage #
Somewhere in your code, you should inject the InternetAccessCubit:
For example using BlocProvider:
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => InternetAccessCubit(),
child: YourWidget(),
);
}
Then you can use the InternetAccessCubitListener widget to listen to the internet access state (make sure the InternetAccessCubit is provided somewhere in the widget tree above this widget):
@override
Widget build(BuildContext context) {
return const InternetAccessCubitListener(
onHasInternetAccess: (context, isFirstCapturedState) =>
print('Connected to the internet'),
onHasNoInternetAccess: (context, isFirstCapturedState) =>
print('Disconnected from the internet'),
child: YourWidget(),
);
}