check_network

Creator: coderz1093

Last updated:

0 purchases

check_network Image
check_network Images

Languages

Categories

Add to Cart

Description:

check network

check_network #

Checking Internet availability by pinging DNS servers to check if the Internet connection is available or not.

Table of contents #

check_network

Table of contents
General info
Setup
Features
How to use

Rebuild Widget


Acknowledgements



General info #
This package is simply ping DNS sever to check if availability of internet is valid one or not. It is useful because by wrapping MaterialApp widget, with InternetStatusProvider will give access to Stream of internet status which then can be used to perform any action based on internet status.
Such as:

Rebuilding Widget if internet is not available
Showing Snackbar if internet is not available
Showing Dialog if internet is not available
Redirecting to another screen if internet is not available
etc.


Setup #
To use this package, you need to install it first. You can install it by running this command:
flutter pub add check_network
copied to clipboard
Or you can add this to your pubspec.yaml file:
dependencies:

check_network: ^0.0.1
copied to clipboard
Features #
List of features ready and TODOs for future development

Check internet availability

To-do list:

Add option to check availability of specific domain address
Support internet speed test

How to use #
To see full example, please check the example folder.

First, you import the package to your dart file.

import 'package:check_network/check_network.dart';
copied to clipboard

Warp the Top Most Widget with the InternetStatusProvider. This will provide the Stream of InternetStatus to all children widgets.

InternetStatusProvider(
currentInternetStatus: CurrentInternetStatus(waitOnConnectedStatusInSeconds: 5),
child: const MyApp(),
),
copied to clipboard

Now we will see how to rebuild the widget when internet status changes.

Rebuild Widget #
Have a Scaffold with StreamBuilder pass
InternetStatusProvider.of(context).onStatusChange to stream parameter that will give access to Internet Status.
And, now simple pass a function that return a widget based on the current internet status which will get recalled when internet status changes.
return Scaffold(
body: StreamBuilder<InternetStatus>(
stream: InternetStatusProvider.of(context).onStatusChange,
builder: (context, snapshot) {
return Center(child: internetStatusWidgetBuilder(snapshot.data));
},
),
);
copied to clipboard
And, that's it we are done. Now, every time the internet status changes, the widget will be rebuilt.
Please see the example in the example for full code and many more examples.
Acknowledgements #

NOTE: This package is a continuation and took inspiration from data_connection_checker.

I would like to appreciate


Dart team for creating such a great language.


Flutter team for creating such a great framework.


Very Good Ventures team for creating such a great open source project and packages.


Flutter Community team for amazing packages and resources.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.