Skip to content

Commit a1e0282

Browse files
onyicodesLucasXu0
andauthored
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 <[email protected]>
1 parent dd1dcba commit a1e0282

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

frontend/app_flowy/lib/core/network_monitor.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class NetworkListener {
1111
late StreamSubscription<ConnectivityResult> _connectivitySubscription;
1212

1313
NetworkListener() {
14-
_connectivitySubscription = _connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
14+
_connectivitySubscription =
15+
_connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
1516
}
1617

1718
Future<void> start() async {
@@ -39,9 +40,11 @@ class NetworkListener {
3940
return NetworkType.Ethernet;
4041
case ConnectivityResult.mobile:
4142
return NetworkType.Cell;
42-
case ConnectivityResult.none:
43-
return NetworkType.UnknownNetworkType;
4443
case ConnectivityResult.bluetooth:
44+
return NetworkType.Bluetooth;
45+
case ConnectivityResult.vpn:
46+
return NetworkType.VPN;
47+
case ConnectivityResult.none:
4548
return NetworkType.UnknownNetworkType;
4649
}
4750
}();

frontend/app_flowy/pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,12 @@ packages:
212212
source: hosted
213213
version: "1.2.4"
214214
connectivity_plus_platform_interface:
215-
dependency: transitive
215+
dependency: "direct main"
216216
description:
217217
name: connectivity_plus_platform_interface
218218
url: "https://pub.dartlang.org"
219219
source: hosted
220-
version: "1.2.0"
220+
version: "1.2.3"
221221
connectivity_plus_web:
222222
dependency: transitive
223223
description:

frontend/app_flowy/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ dependencies:
6868
# file_picker: ^4.2.1
6969
clipboard: ^0.1.3
7070
connectivity_plus: ^2.3.6+1
71+
connectivity_plus_platform_interface: ^1.2.2
7172
easy_localization: ^3.0.0
7273
textfield_tags: ^2.0.0
7374
# The following adds the Cupertino Icons font to your application.

frontend/rust-lib/flowy-net/src/entities/network_state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ pub enum NetworkType {
66
Wifi = 1,
77
Cell = 2,
88
Ethernet = 3,
9+
Bluetooth = 4,
10+
VPN = 5,
911
}
1012

1113
impl NetworkType {
1214
pub fn is_connect(&self) -> bool {
1315
match self {
14-
NetworkType::UnknownNetworkType => false,
15-
NetworkType::Wifi => true,
16-
NetworkType::Cell => true,
17-
NetworkType::Ethernet => true,
16+
NetworkType::UnknownNetworkType | NetworkType::Bluetooth => false,
17+
NetworkType::Wifi | NetworkType::Cell | NetworkType::Ethernet | NetworkType::VPN => true,
1818
}
1919
}
2020
}

0 commit comments

Comments
 (0)