Skip to content

Commit

Permalink
feat: Support latest versions of the plus plugins. (#148)
Browse files Browse the repository at this point in the history
**Requirements**

- [x] I have added test coverage for new or changed functionality
- [x] I have followed the repository's [pull request submission
guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests)
- [x] I have validated my changes against all supported platform
versions

**Related issues**

It's not currently possible to upgrade the Flutter plus plugins in
projects that require the LaunchDarkly SDK until the LaunchDarkly SDK
upgrades its dependencies.

**Describe the solution you've provided**

Upgraded the dependencies.

**Describe alternatives you've considered**

N/A

**Additional context**

N/A
  • Loading branch information
maxlapides authored Mar 27, 2024
1 parent 55b5a2b commit 98dbbed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions packages/flutter_client_sdk/lib/src/flutter_state_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class FlutterStateDetector implements StateDetector {
Stream<NetworkState> get networkState => _networkStateController.stream;

late final LDAppLifecycleListener _lifecycleListener;
late final StreamSubscription<ConnectivityResult> _connectivitySubscription;
late final StreamSubscription<dynamic> _connectivitySubscription;

FlutterStateDetector() {
final initialState = SchedulerBinding.instance.lifecycleState;
Expand All @@ -41,8 +41,15 @@ final class FlutterStateDetector implements StateDetector {
Connectivity().onConnectivityChanged.listen(_setConnectivity);
}

void _setConnectivity(ConnectivityResult connectivityResult) {
if (connectivityResult == ConnectivityResult.none) {
void _setConnectivity(dynamic connectivityResult) {
// TODO: This is a temporary fix to handle the breaking change in
// connectivity_plus v6
final resultsList =
connectivityResult is List ? connectivityResult : [connectivityResult];
final isUnavailable =
resultsList.any((result) => result == ConnectivityResult.none);

if (isUnavailable) {
_networkStateController.sink.add(NetworkState.unavailable);
} else {
_networkStateController.sink.add(NetworkState.available);
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter_client_sdk/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ environment:
dependencies:
flutter:
sdk: flutter
package_info_plus: ">=4.2.0 <6.0.0"
device_info_plus: ^9.1.1
package_info_plus: ">=4.2.0 <7.0.0"
device_info_plus: ">=9.1.1 <11.0.0"
launchdarkly_common_client: 1.2.0
shared_preferences: ^2.2.2
connectivity_plus: ^5.0.2
connectivity_plus: ">=5.0.2 <7.0.0"

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 98dbbed

Please sign in to comment.