Skip to content

Commit

Permalink
Added getConnectivityResult to the ConnectivityHelper class
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Van Zelst committed Sep 16, 2022
1 parent d2748a4 commit 677cca8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.7.3] - 2022-09-16

- Added getConnectivityResult to the ConnectivityHelper class

## [0.7.2] - 2022-06-24
### Updated
- Dependencies
Expand Down
10 changes: 7 additions & 3 deletions lib/src/util/connectivity/connectivity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ class ConnectivityHelper {

/// Returns true if the device is connected to an IP network
Future<bool> hasConnection() async {
return await (_connectivityProvider?.call() ?? Connectivity())
.checkConnectivity() !=
ConnectivityResult.none;
return await getConnectivityResult() != ConnectivityResult.none;
}

/// Returns a stream that monitors the connectivity state of the device
Expand All @@ -22,4 +20,10 @@ class ConnectivityHelper {
.onConnectivityChanged
.map((event) => event != ConnectivityResult.none);
}

/// Returns the method used to connect e.g: Bluetooth, WiFi, Ethernet, Mobile or None
Future<ConnectivityResult> getConnectivityResult() async {
return await (_connectivityProvider?.call() ?? Connectivity())
.checkConnectivity();
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/icapps/flutter-icapps-architecture
repository: https://github.com/icapps/flutter-icapps-architecture
issue_tracker: https://github.com/icapps/flutter-icapps-architecture/issues

version: 0.7.2
version: 0.7.3

environment:
sdk: '>=2.17.0 <3.0.0'
Expand Down
2 changes: 1 addition & 1 deletion test/util/logging/logging_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TestPrefixHelper {
}

@GenerateMocks([], customMocks: [
MockSpec<Log>(returnNullOnMissingStub: true),
MockSpec<Log>(onMissingStub: OnMissingStub.returnDefault),
])
void main() {
group('Static logger', () {
Expand Down

0 comments on commit 677cca8

Please sign in to comment.