Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[connectivity_plus] Update connectivity_plus to 6.1.0 #764

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/connectivity_plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 4 additions & 1 deletion packages/connectivity_plus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -31,3 +31,6 @@ To get connectivity information using this plugin, add below lines under the `<m
<privilege>http://tizen.org/privilege/network.get</privilege>
</privileges>
```

## Limitations
- Multiple connections are not supported, so only the currently connected connection type is provided.
37 changes: 30 additions & 7 deletions packages/connectivity_plus/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class MyHomePage extends StatefulWidget {
}

class _MyHomePageState extends State<MyHomePage> {
ConnectivityResult _connectionStatus = ConnectivityResult.none;
List<ConnectivityResult> _connectionStatus = [ConnectivityResult.none];
final Connectivity _connectivity = Connectivity();
late StreamSubscription<ConnectivityResult> _connectivitySubscription;
late StreamSubscription<List<ConnectivityResult>> _connectivitySubscription;

@override
void initState() {
Expand All @@ -63,7 +63,7 @@ class _MyHomePageState extends State<MyHomePage> {

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

Future<void> _updateConnectionStatus(ConnectivityResult result) async {
Future<void> _updateConnectionStatus(List<ConnectivityResult> 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),
],
),
);
}
}
2 changes: 1 addition & 1 deletion packages/connectivity_plus/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions packages/connectivity_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 encodedList;
xiaowei-guan marked this conversation as resolved.
Show resolved Hide resolved
encodedList.push_back(
flutter::EncodableValue(ConnectionTypeToString(type)));
events_->Success(flutter::EncodableValue(encodedList));
} else {
events_->Error(std::to_string(connection_.GetLastError()),
connection_.GetLastErrorString());
Expand Down Expand Up @@ -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 encodedList;
xiaowei-guan marked this conversation as resolved.
Show resolved Hide resolved
encodedList.push_back(
flutter::EncodableValue(ConnectionTypeToString(type)));
result->Success(flutter::EncodableValue(encodedList));
} else {
result->Error(std::to_string(connection.GetLastError()),
connection.GetLastErrorString());
Expand Down
Loading