Skip to content

Commit 3376417

Browse files
committed
[connectivity_plus] Update connectivity_plus to 6.1.0
- Update connectivity_plus to 6.1.0. - Update connectivity_plus_platform_interface to 2.0.1.
1 parent d5f304e commit 3376417

File tree

6 files changed

+49
-15
lines changed

6 files changed

+49
-15
lines changed

packages/connectivity_plus/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## NEXT
1+
## 1.2.0
22

33
* Update minimum Flutter and Dart version to 3.13 and 3.1.
4+
* Update connectivity_plus to 6.1.0.
5+
* Update connectivity_plus_platform_interface to 2.0.1.
46

57
## 1.1.4
68

packages/connectivity_plus/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This package is not an _endorsed_ implementation of `connectivity_plus`. Therefo
1111
```yaml
1212
dependencies:
1313
connectivity_plus: ^4.0.1
14-
connectivity_plus_tizen: ^1.1.4
14+
connectivity_plus_tizen: ^1.2.0
1515
```
1616
1717
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 `<m
3131
<privilege>http://tizen.org/privilege/network.get</privilege>
3232
</privileges>
3333
```
34+
35+
## Limitations
36+
- Multiple connections are not supported, so only the currently connected connection type is provided.

packages/connectivity_plus/example/lib/main.dart

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class MyHomePage extends StatefulWidget {
4242
}
4343

4444
class _MyHomePageState extends State<MyHomePage> {
45-
ConnectivityResult _connectionStatus = ConnectivityResult.none;
45+
List<ConnectivityResult> _connectionStatus = [ConnectivityResult.none];
4646
final Connectivity _connectivity = Connectivity();
47-
late StreamSubscription<ConnectivityResult> _connectivitySubscription;
47+
late StreamSubscription<List<ConnectivityResult>> _connectivitySubscription;
4848

4949
@override
5050
void initState() {
@@ -63,7 +63,7 @@ class _MyHomePageState extends State<MyHomePage> {
6363

6464
// Platform messages are asynchronous, so we initialize in an async method.
6565
Future<void> initConnectivity() async {
66-
late ConnectivityResult result;
66+
late List<ConnectivityResult> result;
6767
// Platform messages may fail, so we use a try/catch PlatformException.
6868
try {
6969
result = await _connectivity.checkConnectivity();
@@ -82,21 +82,44 @@ class _MyHomePageState extends State<MyHomePage> {
8282
return _updateConnectionStatus(result);
8383
}
8484

85-
Future<void> _updateConnectionStatus(ConnectivityResult result) async {
85+
Future<void> _updateConnectionStatus(List<ConnectivityResult> result) async {
8686
setState(() {
8787
_connectionStatus = result;
8888
});
89+
// ignore: avoid_print
90+
print('Connectivity changed: $_connectionStatus');
8991
}
9092

9193
@override
9294
Widget build(BuildContext context) {
9395
return Scaffold(
9496
appBar: AppBar(
95-
title: const Text('Connectivity example app'),
97+
title: const Text('Connectivity Plus Example'),
9698
elevation: 4,
9799
),
98-
body: Center(
99-
child: Text('Connection Status: ${_connectionStatus.toString()}')),
100+
body: Column(
101+
mainAxisSize: MainAxisSize.min,
102+
children: [
103+
const Spacer(flex: 2),
104+
Text(
105+
'Active connection types:',
106+
style: Theme.of(context).textTheme.headlineMedium,
107+
),
108+
const Spacer(),
109+
ListView(
110+
shrinkWrap: true,
111+
children: List.generate(
112+
_connectionStatus.length,
113+
(index) => Center(
114+
child: Text(
115+
_connectionStatus[index].toString(),
116+
style: Theme.of(context).textTheme.headlineSmall,
117+
),
118+
)),
119+
),
120+
const Spacer(flex: 2),
121+
],
122+
),
100123
);
101124
}
102125
}

packages/connectivity_plus/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
flutter: ">=3.13.0"
88

99
dependencies:
10-
connectivity_plus: ^4.0.1
10+
connectivity_plus: ^6.1.0
1111
connectivity_plus_tizen:
1212
path: ../
1313
flutter:

packages/connectivity_plus/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: connectivity_plus_tizen
22
description: Tizen implementation of the connectivity_plus plugin.
33
homepage: https://github.com/flutter-tizen/plugins
44
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/connectivity_plus
5-
version: 1.1.4
5+
version: 1.2.0
66

77
environment:
88
sdk: ">=3.1.0 <4.0.0"
9-
flutter: ">=3.13.0"
9+
flutter: ">=3.3.0"
1010

1111
flutter:
1212
plugin:
@@ -16,7 +16,7 @@ flutter:
1616
fileName: connectivity_plus_tizen_plugin.h
1717

1818
dependencies:
19-
connectivity_plus_platform_interface: ^1.2.4
19+
connectivity_plus_platform_interface: ^2.0.1
2020
flutter:
2121
sdk: flutter
2222

packages/connectivity_plus/tizen/src/connectivity_plus_tizen_plugin.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ class ConnectivityStreamHandler : public FlStreamHandler {
5252

5353
ConnectionTypeCallback callback = [this](ConnectionType type) -> void {
5454
if (type != ConnectionType::kError) {
55-
events_->Success(flutter::EncodableValue(ConnectionTypeToString(type)));
55+
flutter::EncodableList encodedList;
56+
encodedList.push_back(
57+
flutter::EncodableValue(ConnectionTypeToString(type)));
58+
events_->Success(flutter::EncodableValue(encodedList));
5659
} else {
5760
events_->Error(std::to_string(connection_.GetLastError()),
5861
connection_.GetLastErrorString());
@@ -117,7 +120,10 @@ class ConnectivityPlusTizenPlugin : public flutter::Plugin {
117120
Connection connection;
118121
ConnectionType type = connection.GetType();
119122
if (type != ConnectionType::kError) {
120-
result->Success(flutter::EncodableValue(ConnectionTypeToString(type)));
123+
flutter::EncodableList encodedList;
124+
encodedList.push_back(
125+
flutter::EncodableValue(ConnectionTypeToString(type)));
126+
result->Success(flutter::EncodableValue(encodedList));
121127
} else {
122128
result->Error(std::to_string(connection.GetLastError()),
123129
connection.GetLastErrorString());

0 commit comments

Comments
 (0)