Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marchdev-tk/cross_connectivity
A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Android, Web, Windows, Linux and macOS.
https://github.com/marchdev-tk/cross_connectivity
android connectivity dart dart2 dartlang flutter flutter-package flutter-plugin internet-connection internet-connection-checker internet-connectivity ios linux macos macosx web windows
Last synced: 4 days ago
JSON representation
A Flutter plugin for handling Connectivity and REAL Connection state in the mobile, web and desktop platforms. Supports iOS, Android, Web, Windows, Linux and macOS.
- Host: GitHub
- URL: https://github.com/marchdev-tk/cross_connectivity
- Owner: marchdev-tk
- License: bsd-3-clause
- Created: 2020-03-12T11:21:21.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-09T15:48:28.000Z (3 months ago)
- Last Synced: 2025-01-16T23:01:00.685Z (11 days ago)
- Topics: android, connectivity, dart, dart2, dartlang, flutter, flutter-package, flutter-plugin, internet-connection, internet-connection-checker, internet-connectivity, ios, linux, macos, macosx, web, windows
- Language: C++
- Homepage:
- Size: 2.55 MB
- Stars: 30
- Watchers: 1
- Forks: 16
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Authors: AUTHORS
Awesome Lists containing this project
README
# cross_connectivity
![Build](https://github.com/marchdev-tk/cross_connectivity/workflows/build/badge.svg)
[![Pub](https://img.shields.io/pub/v/cross_connectivity.svg)](https://pub.dartlang.org/packages/cross_connectivity)
![GitHub](https://img.shields.io/github/license/marchdev-tk/cross_connectivity)
![GitHub stars](https://img.shields.io/github/stars/marchdev-tk/cross_connectivity?style=social)A Flutter plugin for handling `Connectivity` and `REAL Connection` state in the mobile, web and desktop platforms. Supports iOS, Android, Web, Windows, Linux and macOS.
## Getting Started
In order to use this plugin, add dependency in the `pubspec.yaml`:
```yaml
cross_connectivity: any
```or
```yaml
cross_connectivity:
git:
url: https://github.com/marchdev-tk/cross_connectivity
```Add an import to dart file:
```dart
import 'package:cross_connectivity/cross_connectivity.dart';
```### Samples
Web sample:
![Web Sample](../assets/cc_web.gif?raw=true)
Desktop sample:
![Desktop Sample](../assets/cc_desktop.gif?raw=true)
Mobile sample:
![Mobile Sample](../assets/cc_mobile.gif?raw=true)
### Usage
#### Functional approach
This plugin provides two streams:
* `isConnected` that shows whether the device is `REALLY` connected to the network or not.
* `onConnectivityChanged` that it will not let you know about state of the `REAL` network connection. It only shows connectivity state.Also for `one time` check could be used following methods:
* `checkConnection()` that is working like `isConnected`, but returns `Future` instread of `Stream`.
* `checkConnectivity()` that is working like `onConnectivityChanged`, but returns `Future` instread of `Stream`.There are no more methods (they are working only on Android/iOS/macOS):
* `getWifiName()` - Obtains the wifi name (SSID) of the connected network.
* `getWifiBSSID()` - Obtains the wifi BSSID of the connected network.
* `getWifiIP()` - Obtains the IP address of the connected wifi network.They are removed to [wifi_info_flutter](https://github.com/flutter/plugins/tree/master/packages/wifi_info_flutter).
##### Migration guide:
If you don't use any of the above APIs, your code should work as is. In addition, you can also remove `NSLocationAlwaysAndWhenInUseUsageDescription` and `NSLocationWhenInUseUsageDescription` in `ios/Runner/Info.plist`
If you use any of the above APIs, you can find the same APIs in the [wifi_info_flutter](https://github.com/flutter/plugins/tree/master/packages/wifi_info_flutter/wifi_info_flutter) plugin.
For example, to migrate `getWifiName`, use the new plugin:
```dart
final WifiInfo _wifiInfo = WifiInfo();
final String wifiName = await _wifiInfo.getWifiName();
```#### Widget approach
As an alteration to funcitonal approach could be used `ConnectivityBuilder` widget as follows:
```dart
ConnectivityBuilder(
builder: (context, isConnected, status) => Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
isConnected == true
? Icons.signal_wifi_4_bar
: Icons.signal_wifi_off,
color: isConnected == true ? Colors.green : Colors.red,
),
const SizedBox(width: 8),
Text(
'$status',
style: TextStyle(
color: status != ConnectivityStatus.none
? Colors.green
: Colors.red,
),
),
],
),
)
```## Feature requests and Bug reports
Feel free to post a feature requests or report a bug [here](https://github.com/marchdev-tk/cross_connectivity/issues).