Skip to content

Commit

Permalink
Bumped dependencies to support connectivity_plus 6.x (#65)
Browse files Browse the repository at this point in the history
Hey @jogboms , I took the chance to bump some dependencies to support
newer versions like connectivity_plus and network_info_plus. I decided
to bump to a major since connectivity_plus decided to change all their
signatures 😄

I hope this helps. Feel free to ask for changes, I'll be happy to help.

Closes #64
  • Loading branch information
jogboms committed Jul 11, 2024
2 parents 356710e + 33c3cb1 commit 0193ce8
Show file tree
Hide file tree
Showing 20 changed files with 251 additions and 183 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [4.0.0]

Bump `package:connectivity_plus` to `^6.0.3`
Bump `package:network_info_plus` to `^5.0.3`

## [3.0.1]

Bump `package:connectivity_plus` to `^5.0.1`
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A tidy utility to handle offline/online connectivity like a Boss. It provides su

```yaml
dependencies:
flutter_offline: "^3.0.1"
flutter_offline: "^4.0.0"
```
### ⚡️ Import
Expand Down Expand Up @@ -39,10 +39,10 @@ class DemoPage extends StatelessWidget {
body: OfflineBuilder(
connectivityBuilder: (
BuildContext context,
ConnectivityResult connectivity,
List<ConnectivityResult> connectivity,
Widget child,
) {
final bool connected = connectivity != ConnectivityResult.none;
final bool connected = !connectivity.contains(ConnectivityResult.none);
return new Stack(
fit: StackFit.expand,
children: [
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 19
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
3 changes: 1 addition & 2 deletions example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
3 changes: 1 addition & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>

Expand Down
3 changes: 1 addition & 2 deletions example/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.example">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
3 changes: 3 additions & 0 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
4 changes: 2 additions & 2 deletions example/lib/widgets/demo_1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class Demo1 extends StatelessWidget {
return OfflineBuilder(
connectivityBuilder: (
BuildContext context,
ConnectivityResult connectivity,
List<ConnectivityResult> connectivity,
Widget child,
) {
final connected = connectivity != ConnectivityResult.none;
final connected = !connectivity.contains(ConnectivityResult.none);
return Stack(
fit: StackFit.expand,
children: [
Expand Down
4 changes: 2 additions & 2 deletions example/lib/widgets/demo_2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class Demo2 extends StatelessWidget {
return OfflineBuilder(
connectivityBuilder: (
BuildContext context,
ConnectivityResult connectivity,
List<ConnectivityResult> connectivity,
Widget child,
) {
if (connectivity == ConnectivityResult.none) {
if (connectivity.contains(ConnectivityResult.none)) {
return Container(
color: Colors.white,
child: const Center(
Expand Down
4 changes: 2 additions & 2 deletions example/lib/widgets/demo_3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class Demo3 extends StatelessWidget {
debounceDuration: Duration.zero,
connectivityBuilder: (
BuildContext context,
ConnectivityResult connectivity,
List<ConnectivityResult> connectivity,
Widget child,
) {
if (connectivity == ConnectivityResult.none) {
if (connectivity.contains(ConnectivityResult.none)) {
return Container(
color: Colors.white70,
child: const Center(
Expand Down
78 changes: 51 additions & 27 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ packages:
dependency: transitive
description:
name: connectivity_plus
sha256: b502a681ba415272ecc41400bd04fe543ed1a62632137dc84d25a91e7746f55f
sha256: db7a4e143dc72cc3cb2044ef9b052a7ebfe729513e6a82943bc3526f784365b8
url: "https://pub.dev"
source: hosted
version: "5.0.1"
version: "6.0.3"
connectivity_plus_platform_interface:
dependency: transitive
description:
name: connectivity_plus_platform_interface
sha256: cf1d1c28f4416f8c654d7dc3cd638ec586076255d407cef3ddbdaf178272a71a
sha256: b6a56efe1e6675be240de39107281d4034b64ac23438026355b4234042a35adb
url: "https://pub.dev"
source: hosted
version: "1.2.4"
version: "2.0.0"
dbus:
dependency: transitive
description:
Expand Down Expand Up @@ -108,7 +108,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.0.1"
version: "4.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -119,14 +119,30 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "0.6.7"
version: "3.0.1"
lints:
dependency: transitive
description:
Expand All @@ -139,42 +155,42 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.12.0"
network_info_plus:
dependency: transitive
description:
name: network_info_plus
sha256: "5a79c244070fb7f7d10fbcfa24eed315252b4e662f42658029871d31afdbba9e"
sha256: "5bd4b86e28fed5ed4e6ac7764133c031dfb7d3f46aa2a81b46f55038aa78ecc0"
url: "https://pub.dev"
source: hosted
version: "4.0.1"
version: "5.0.3"
network_info_plus_platform_interface:
dependency: transitive
description:
name: network_info_plus_platform_interface
sha256: "881f5029c5edaf19c616c201d3d8b366c5b1384afd5c1da5a49e4345de82fb8b"
sha256: "2e193d61d3072ac17824638793d3b89c6d581ce90c11604f4ca87311b42f2706"
url: "https://pub.dev"
source: hosted
version: "1.1.3"
version: "2.0.0"
nm:
dependency: transitive
description:
Expand All @@ -187,10 +203,10 @@ packages:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
petitparser:
dependency: transitive
description:
Expand All @@ -203,10 +219,10 @@ packages:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "075f927ebbab4262ace8d0b283929ac5410c0ac4e7fc123c76429564facfb757"
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
version: "2.1.8"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -256,10 +272,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
vector_math:
dependency: transitive
description:
Expand All @@ -268,6 +284,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "14.2.1"
web:
dependency: transitive
description:
Expand All @@ -293,5 +317,5 @@ packages:
source: hosted
version: "6.3.0"
sdks:
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.3.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
10 changes: 5 additions & 5 deletions lib/src/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ typedef ValueWidgetBuilder<T> = Widget Function(BuildContext context, T value, W
class OfflineBuilder extends StatefulWidget {
factory OfflineBuilder({
Key? key,
required ValueWidgetBuilder<ConnectivityResult> connectivityBuilder,
required ValueWidgetBuilder<List<ConnectivityResult>> connectivityBuilder,
Duration debounceDuration = kOfflineDebounceDuration,
WidgetBuilder? builder,
Widget? child,
Expand Down Expand Up @@ -53,7 +53,7 @@ class OfflineBuilder extends StatefulWidget {
final Duration debounceDuration;

/// Used for building the Offline and/or Online UI
final ValueWidgetBuilder<ConnectivityResult> connectivityBuilder;
final ValueWidgetBuilder<List<ConnectivityResult>> connectivityBuilder;

/// Used for building the child widget
final WidgetBuilder? builder;
Expand All @@ -69,7 +69,7 @@ class OfflineBuilder extends StatefulWidget {
}

class OfflineBuilderState extends State<OfflineBuilder> {
late Stream<ConnectivityResult> _connectivityStream;
late Stream<List<ConnectivityResult>> _connectivityStream;

@override
void initState() {
Expand All @@ -82,9 +82,9 @@ class OfflineBuilderState extends State<OfflineBuilder> {

@override
Widget build(BuildContext context) {
return StreamBuilder<ConnectivityResult>(
return StreamBuilder<List<ConnectivityResult>>(
stream: _connectivityStream,
builder: (BuildContext context, AsyncSnapshot<ConnectivityResult> snapshot) {
builder: (BuildContext context, AsyncSnapshot<List<ConnectivityResult>> snapshot) {
if (!snapshot.hasData && !snapshot.hasError) {
return const SizedBox();
}
Expand Down
22 changes: 11 additions & 11 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import 'dart:async';

import 'package:connectivity_plus/connectivity_plus.dart';

StreamTransformer<ConnectivityResult, ConnectivityResult> debounce(
StreamTransformer<List<ConnectivityResult>, List<ConnectivityResult>> debounce(
Duration debounceDuration,
) {
var seenFirstData = false;
Timer? debounceTimer;

return StreamTransformer<ConnectivityResult, ConnectivityResult>.fromHandlers(
handleData: (ConnectivityResult data, EventSink<ConnectivityResult> sink) {
return StreamTransformer<List<ConnectivityResult>, List<ConnectivityResult>>.fromHandlers(
handleData: (List<ConnectivityResult> data, EventSink<List<ConnectivityResult>> sink) {
if (seenFirstData) {
debounceTimer?.cancel();
debounceTimer = Timer(debounceDuration, () => sink.add(data));
Expand All @@ -18,25 +18,25 @@ StreamTransformer<ConnectivityResult, ConnectivityResult> debounce(
seenFirstData = true;
}
},
handleDone: (EventSink<ConnectivityResult> sink) {
handleDone: (EventSink<List<ConnectivityResult>> sink) {
debounceTimer?.cancel();
sink.close();
},
);
}

StreamTransformer<ConnectivityResult, ConnectivityResult> startsWith(
ConnectivityResult data,
StreamTransformer<List<ConnectivityResult>, List<ConnectivityResult>> startsWith(
List<ConnectivityResult> data,
) {
return StreamTransformer<ConnectivityResult, ConnectivityResult>(
return StreamTransformer<List<ConnectivityResult>, List<ConnectivityResult>>(
(
Stream<ConnectivityResult> input,
Stream<List<ConnectivityResult>> input,
bool cancelOnError,
) {
StreamController<ConnectivityResult>? controller;
late StreamSubscription<ConnectivityResult> subscription;
StreamController<List<ConnectivityResult>>? controller;
late StreamSubscription<List<ConnectivityResult>> subscription;

controller = StreamController<ConnectivityResult>(
controller = StreamController<List<ConnectivityResult>>(
sync: true,
onListen: () => controller?.add(data),
onPause: ([Future<dynamic>? resumeSignal]) => subscription.pause(resumeSignal),
Expand Down
Loading

0 comments on commit 0193ce8

Please sign in to comment.