Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class Connectivity {
static final String CONNECTIVITY_NONE = "none";
static final String CONNECTIVITY_WIFI = "wifi";
static final String CONNECTIVITY_MOBILE = "mobile";
static final String CONNECTIVITY_ETHERNET = "ethernet";
private ConnectivityManager connectivityManager;

public Connectivity(ConnectivityManager connectivityManager) {
Expand All @@ -27,10 +28,12 @@ String getNetworkType() {
if (capabilities == null) {
return CONNECTIVITY_NONE;
}
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
|| capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
return CONNECTIVITY_WIFI;
}
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) {
return CONNECTIVITY_ETHERNET;
}
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
return CONNECTIVITY_MOBILE;
}
Expand All @@ -49,6 +52,7 @@ private String getNetworkTypeLegacy() {
int type = info.getType();
switch (type) {
case ConnectivityManager.TYPE_ETHERNET:
return "ethernet";
case ConnectivityManager.TYPE_WIFI:
case ConnectivityManager.TYPE_WIMAX:
return "wifi";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.0

- Add ethernet as connectivity result

## 1.0.3

- Update D-Bus package dependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ class ConnectivityLinux extends ConnectivityPlatform {
if (client.connectivity != NetworkManagerConnectivityState.full) {
return ConnectivityResult.none;
}
// ### TODO: ConnectivityResult.ethernet
if (client.primaryConnectionType.contains('wireless') ||
client.primaryConnectionType.contains('ethernet')) {
if (client.primaryConnectionType.contains('wireless')) {
return ConnectivityResult.wifi;
}
if (client.primaryConnectionType.contains('ethernet')) {
return ConnectivityResult.ethernet;
}
return ConnectivityResult.mobile;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: connectivity_plus_linux
description: Linux implementation of the connectivity_plus plugin
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/
version: 1.0.3
version: 1.1.0

environment:
sdk: ">=2.12.0 <3.0.0"
Expand All @@ -11,7 +11,7 @@ environment:
dependencies:
flutter:
sdk: flutter
connectivity_plus_platform_interface: ^1.0.2
connectivity_plus_platform_interface: ^1.1.0
dbus: ^0.5.1
meta: ^1.3.0
nm: ^0.3.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.0

- Add ethernet as connectivity result

## 1.0.2

- Update connectivity plus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ enum ConnectivityResult {
/// WiFi: Device connected via Wi-Fi
wifi,

/// Ethernet: Device connected to ethernet network
ethernet,

/// Mobile: Device connected to cellular network
mobile,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ ConnectivityResult parseConnectivityResult(String state) {
switch (state) {
case 'wifi':
return ConnectivityResult.wifi;
case 'ethernet':
return ConnectivityResult.ethernet;
case 'mobile':
return ConnectivityResult.mobile;
case 'none':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: connectivity_plus_platform_interface
description: A common platform interface for the connectivity_plus plugin.
version: 1.0.2
version: 1.1.0
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand Down
4 changes: 4 additions & 0 deletions packages/connectivity_plus/connectivity_plus_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.0

- Add ethernet as connectivity result

## 1.0.2

- Update connectivity plus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ ConnectivityResult networkInformationToConnectivityResult(
if (info.downlink == 0 && info.rtt == 0) {
return ConnectivityResult.none;
}
if (info.effectiveType != null) {
return _effectiveTypeToConnectivityResult(info.effectiveType!);
}
if (info.type != null) {
return _typeToConnectivityResult(info.type!);
}
if (info.effectiveType != null) {
return _effectiveTypeToConnectivityResult(info.effectiveType!);
}
return ConnectivityResult.none;
}

Expand Down Expand Up @@ -42,6 +42,8 @@ ConnectivityResult _typeToConnectivityResult(String type) {
case 'other':
case 'unknown':
return ConnectivityResult.mobile;
case 'ethernet':
return ConnectivityResult.ethernet;
default:
return ConnectivityResult.wifi;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: connectivity_plus_web
description: An implementation for the web platform of the Flutter `connectivity_plus` plugin. This uses the NetworkInformation Web API, with a fallback to Navigator.onLine.
version: 1.0.2
version: 1.1.0
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand Down