diff --git a/packages/connectivity_plus/CHANGELOG.md b/packages/connectivity_plus/CHANGELOG.md index 523332b81..1562ffaad 100644 --- a/packages/connectivity_plus/CHANGELOG.md +++ b/packages/connectivity_plus/CHANGELOG.md @@ -1,6 +1,8 @@ -## NEXT +## 1.2.0 * Update minimum Flutter and Dart version to 3.13 and 3.1. +* Update connectivity_plus to 6.1.0. +* Update connectivity_plus_platform_interface to 2.0.1. ## 1.1.4 diff --git a/packages/connectivity_plus/README.md b/packages/connectivity_plus/README.md index 8ac92ecfb..73bfcf0c2 100644 --- a/packages/connectivity_plus/README.md +++ b/packages/connectivity_plus/README.md @@ -11,7 +11,7 @@ This package is not an _endorsed_ implementation of `connectivity_plus`. Therefo ```yaml dependencies: connectivity_plus: ^4.0.1 - connectivity_plus_tizen: ^1.1.4 + connectivity_plus_tizen: ^1.2.0 ``` Then you can import `connectivity_plus` in your Dart code: @@ -31,3 +31,6 @@ To get connectivity information using this plugin, add below lines under the `http://tizen.org/privilege/network.get ``` + +## Limitations +- Multiple connections are not supported, so only the currently connected connection type is provided. diff --git a/packages/connectivity_plus/example/lib/main.dart b/packages/connectivity_plus/example/lib/main.dart index 118a2b121..29927da5d 100644 --- a/packages/connectivity_plus/example/lib/main.dart +++ b/packages/connectivity_plus/example/lib/main.dart @@ -42,9 +42,9 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - ConnectivityResult _connectionStatus = ConnectivityResult.none; + List _connectionStatus = [ConnectivityResult.none]; final Connectivity _connectivity = Connectivity(); - late StreamSubscription _connectivitySubscription; + late StreamSubscription> _connectivitySubscription; @override void initState() { @@ -63,7 +63,7 @@ class _MyHomePageState extends State { // Platform messages are asynchronous, so we initialize in an async method. Future initConnectivity() async { - late ConnectivityResult result; + late List result; // Platform messages may fail, so we use a try/catch PlatformException. try { result = await _connectivity.checkConnectivity(); @@ -82,21 +82,44 @@ class _MyHomePageState extends State { return _updateConnectionStatus(result); } - Future _updateConnectionStatus(ConnectivityResult result) async { + Future _updateConnectionStatus(List result) async { setState(() { _connectionStatus = result; }); + // ignore: avoid_print + print('Connectivity changed: $_connectionStatus'); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: const Text('Connectivity example app'), + title: const Text('Connectivity Plus Example'), elevation: 4, ), - body: Center( - child: Text('Connection Status: ${_connectionStatus.toString()}')), + body: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Spacer(flex: 2), + Text( + 'Active connection types:', + style: Theme.of(context).textTheme.headlineMedium, + ), + const Spacer(), + ListView( + shrinkWrap: true, + children: List.generate( + _connectionStatus.length, + (index) => Center( + child: Text( + _connectionStatus[index].toString(), + style: Theme.of(context).textTheme.headlineSmall, + ), + )), + ), + const Spacer(flex: 2), + ], + ), ); } } diff --git a/packages/connectivity_plus/example/pubspec.yaml b/packages/connectivity_plus/example/pubspec.yaml index 1c4bebdeb..5f3660be0 100644 --- a/packages/connectivity_plus/example/pubspec.yaml +++ b/packages/connectivity_plus/example/pubspec.yaml @@ -7,7 +7,7 @@ environment: flutter: ">=3.13.0" dependencies: - connectivity_plus: ^4.0.1 + connectivity_plus: ^6.1.0 connectivity_plus_tizen: path: ../ flutter: diff --git a/packages/connectivity_plus/pubspec.yaml b/packages/connectivity_plus/pubspec.yaml index 7f132caaf..33826c1f4 100644 --- a/packages/connectivity_plus/pubspec.yaml +++ b/packages/connectivity_plus/pubspec.yaml @@ -2,11 +2,11 @@ name: connectivity_plus_tizen description: Tizen implementation of the connectivity_plus plugin. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/master/packages/connectivity_plus -version: 1.1.4 +version: 1.2.0 environment: sdk: ">=3.1.0 <4.0.0" - flutter: ">=3.13.0" + flutter: ">=3.3.0" flutter: plugin: @@ -16,7 +16,7 @@ flutter: fileName: connectivity_plus_tizen_plugin.h dependencies: - connectivity_plus_platform_interface: ^1.2.4 + connectivity_plus_platform_interface: ^2.0.1 flutter: sdk: flutter diff --git a/packages/connectivity_plus/tizen/src/connectivity_plus_tizen_plugin.cc b/packages/connectivity_plus/tizen/src/connectivity_plus_tizen_plugin.cc index 76ff27a52..1691507a1 100644 --- a/packages/connectivity_plus/tizen/src/connectivity_plus_tizen_plugin.cc +++ b/packages/connectivity_plus/tizen/src/connectivity_plus_tizen_plugin.cc @@ -52,7 +52,10 @@ class ConnectivityStreamHandler : public FlStreamHandler { ConnectionTypeCallback callback = [this](ConnectionType type) -> void { if (type != ConnectionType::kError) { - events_->Success(flutter::EncodableValue(ConnectionTypeToString(type))); + flutter::EncodableList encoded_list; + encoded_list.push_back( + flutter::EncodableValue(ConnectionTypeToString(type))); + events_->Success(flutter::EncodableValue(encoded_list)); } else { events_->Error(std::to_string(connection_.GetLastError()), connection_.GetLastErrorString()); @@ -117,7 +120,10 @@ class ConnectivityPlusTizenPlugin : public flutter::Plugin { Connection connection; ConnectionType type = connection.GetType(); if (type != ConnectionType::kError) { - result->Success(flutter::EncodableValue(ConnectionTypeToString(type))); + flutter::EncodableList encoded_list; + encoded_list.push_back( + flutter::EncodableValue(ConnectionTypeToString(type))); + result->Success(flutter::EncodableValue(encoded_list)); } else { result->Error(std::to_string(connection.GetLastError()), connection.GetLastErrorString());