mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-25 07:07:32 -04:00
fix: NetworkType null safety issues (#1435)
* fix: Networktype null safety issues Networktype returns nulls when the connectivity result is vpn resulting to null safety issues. Implemented a case for when the connectivity result is vpn to resolve this issue. * chore: update connectivity_plus_platform_interface ^1.2.2 * chore: update network state on Rust side Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
parent
dd1dcba599
commit
a1e0282df0
4 changed files with 13 additions and 9 deletions
|
@ -11,7 +11,8 @@ class NetworkListener {
|
||||||
late StreamSubscription<ConnectivityResult> _connectivitySubscription;
|
late StreamSubscription<ConnectivityResult> _connectivitySubscription;
|
||||||
|
|
||||||
NetworkListener() {
|
NetworkListener() {
|
||||||
_connectivitySubscription = _connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
|
_connectivitySubscription =
|
||||||
|
_connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> start() async {
|
Future<void> start() async {
|
||||||
|
@ -39,9 +40,11 @@ class NetworkListener {
|
||||||
return NetworkType.Ethernet;
|
return NetworkType.Ethernet;
|
||||||
case ConnectivityResult.mobile:
|
case ConnectivityResult.mobile:
|
||||||
return NetworkType.Cell;
|
return NetworkType.Cell;
|
||||||
case ConnectivityResult.none:
|
|
||||||
return NetworkType.UnknownNetworkType;
|
|
||||||
case ConnectivityResult.bluetooth:
|
case ConnectivityResult.bluetooth:
|
||||||
|
return NetworkType.Bluetooth;
|
||||||
|
case ConnectivityResult.vpn:
|
||||||
|
return NetworkType.VPN;
|
||||||
|
case ConnectivityResult.none:
|
||||||
return NetworkType.UnknownNetworkType;
|
return NetworkType.UnknownNetworkType;
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -212,12 +212,12 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.4"
|
version: "1.2.4"
|
||||||
connectivity_plus_platform_interface:
|
connectivity_plus_platform_interface:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: connectivity_plus_platform_interface
|
name: connectivity_plus_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.3"
|
||||||
connectivity_plus_web:
|
connectivity_plus_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -68,6 +68,7 @@ dependencies:
|
||||||
# file_picker: ^4.2.1
|
# file_picker: ^4.2.1
|
||||||
clipboard: ^0.1.3
|
clipboard: ^0.1.3
|
||||||
connectivity_plus: ^2.3.6+1
|
connectivity_plus: ^2.3.6+1
|
||||||
|
connectivity_plus_platform_interface: ^1.2.2
|
||||||
easy_localization: ^3.0.0
|
easy_localization: ^3.0.0
|
||||||
textfield_tags: ^2.0.0
|
textfield_tags: ^2.0.0
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
|
|
|
@ -6,15 +6,15 @@ pub enum NetworkType {
|
||||||
Wifi = 1,
|
Wifi = 1,
|
||||||
Cell = 2,
|
Cell = 2,
|
||||||
Ethernet = 3,
|
Ethernet = 3,
|
||||||
|
Bluetooth = 4,
|
||||||
|
VPN = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NetworkType {
|
impl NetworkType {
|
||||||
pub fn is_connect(&self) -> bool {
|
pub fn is_connect(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
NetworkType::UnknownNetworkType => false,
|
NetworkType::UnknownNetworkType | NetworkType::Bluetooth => false,
|
||||||
NetworkType::Wifi => true,
|
NetworkType::Wifi | NetworkType::Cell | NetworkType::Ethernet | NetworkType::VPN => true,
|
||||||
NetworkType::Cell => true,
|
|
||||||
NetworkType::Ethernet => true,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue