ConnectivityService class
ConnectivityService provides a global way to monitor internet connectivity.
This service utilizes the connectivity_plus package to detect changes in
network connectivity and validates internet access by making HTTP requests.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
connectivityStream
→ Stream<
bool> -
A stream that emits connectivity status (
truefor connected,falsefor disconnected).no setter
Static Methods
-
startConnectionNotifier(
{String connectedToastMessage = "You are now connected to the Internet.", String disconnectedToastMessage = "No internet connection. Please check your network.", String testUrl = 'https://google.com', Color connectedToastBackgroundColor = Colors.green, Color disconnectedToastBackgroundColor = Colors.red, String connectedWebToastBackgroundHexColor = "#4CAF50", String disconnectedWebToastBackgroundHexColor = "#F44336", ToastGravity toastGravity = ToastGravity.BOTTOM, double toastFontSize = 16.0, bool showToasts = true, Duration debounceDuration = const Duration(milliseconds: 500), Function? onConnected, Function? onDisconnected}) → void - Starts a global connection notifier with optional toast messages.
-
stopNotifier(
) → void - Stops the connection notifier and cleans up resources.
-
validateInternetConnection(
{String testUrl = 'https://google.com', int retries = 3, Duration retryDelay = const Duration(seconds: 2)}) → Future< bool> - Validates internet connectivity by making an HTTP request.