pinger_internet_status 0.1.1
pinger_internet_status: ^0.1.1 copied to clipboard
A Flutter package for monitoring internet connectivity by periodically pinging specified URLs.
Pinger Internet Status Package #
This package provides a simple yet powerful way to monitor internet connectivity within your Flutter applications. Featuring PingerInternetStatus, a class that periodically checks internet connectivity by pinging specified URLs, and InternetStatusBuilder, a widget that reacts to connectivity changes, this package ensures your app remains responsive and informative regarding its connection status.
Features #
- Internet Connectivity Monitoring: Periodically ping specified URLs to check for internet connectivity.
- Asynchronous Updates: Utilizes Dart isolates to perform connectivity checks without blocking the main UI thread.
- Dynamic UI Responses: Includes
PingerBuilder, a widget that updates its display based on the current internet connectivity status. - Customizable Connectivity Checks: Configure URLs and ping intervals to suit your app's needs.
- Optional Logging: Control console logging for connectivity checks and ping results.
Getting Started #
To get started with the Internet Connectivity Widget Package, follow these simple steps:
Installation #
-
Add
pinger_internet_statusto yourpubspec.yamlunder the dependencies section:dependencies: flutter: sdk: flutter pinger_internet_status: 0.1.0 -
Import the package in your Flutter app:
import 'package:your_package_name/pinger_internet_status.dart';
Usage #
-
Initialize
PingerInternetStatus:Create an instance of
PingerInternetStatus, specifying the URLs to ping and the timeout interval.final PingerInternetStatus pingerInternetStatus = PingerInternetStatus( urls: ['https://google.com', 'https://example.com'], timeOut: 2, // Timeout in seconds logger: true, // Enable logging for debugging purposes ); -
Use
InternetStatusBuilderin Your Widget Tree:Incorporate
InternetStatusBuilderinto your app's widget tree to dynamically display widgets based on the internet connectivity status.PingerBuilder( statusChecker: pingerInternetStatus, connectedWidget: Text('Connected to the Internet'), disconnectedWidget: Text('Disconnected from the Internet'), preInitWidget: CircularProgressIndicator(), // Optional: Shown until the first connectivity check completes. )
Example #
See the /example folder for a detailed Flutter app example using this package.
Contributing #
Contributions are welcome! If you find a bug or have a feature request, please open an issue on our GitHub repository.
License #
This package is licensed under the MIT License. See the LICENSE file for details.