From 690e1982e9ac493b422287404441d3ab14039949 Mon Sep 17 00:00:00 2001 From: Swift Kim Date: Tue, 30 Mar 2021 15:05:38 +0900 Subject: [PATCH] Migrate to Dart 2.12 and Flutter 2.0 (#50) * Update battery * Update connectivity * Update device_info * Update image_picker * Update integration_test * Update package_info * Update path_provider * Update sensors * Update share * Update shared_preferences * Update url_launcher * Update wifi_info_flutter * Update github workflow --- .github/workflows/dart.yml | 4 +- README.md | 2 +- packages/battery/CHANGELOG.md | 8 + packages/battery/LICENSE | 2 +- packages/battery/README.md | 4 +- .../integration_test/battery_test.dart | 8 +- packages/battery/example/lib/main.dart | 15 +- packages/battery/example/pubspec.yaml | 15 +- .../example/test_driver/integration_test.dart | 2 + packages/battery/pubspec.yaml | 12 +- packages/connectivity/CHANGELOG.md | 11 +- packages/connectivity/LICENSE | 2 +- packages/connectivity/README.md | 5 +- packages/connectivity/example/README.md | 4 +- .../integration_test/connectivity_test.dart | 5 +- packages/connectivity/example/lib/main.dart | 12 +- packages/connectivity/example/pubspec.yaml | 18 +- .../example/test_driver/integration_test.dart | 2 + packages/connectivity/pubspec.yaml | 18 +- .../tizen/src/connectivity_tizen_plugin.cc | 4 +- packages/device_info/CHANGELOG.md | 13 +- packages/device_info/LICENSE | 2 +- packages/device_info/README.md | 2 +- .../integration_test/device_info_test.dart | 9 +- packages/device_info/example/lib/main.dart | 15 +- packages/device_info/example/pubspec.yaml | 13 +- .../example/test_driver/integration_test.dart | 2 + .../device_info/lib/device_info_tizen.dart | 159 +++++--- packages/device_info/pubspec.yaml | 13 +- packages/image_picker/CHANGELOG.md | 9 + packages/image_picker/LICENSE | 2 +- packages/image_picker/README.md | 8 +- packages/image_picker/example/README.md | 2 +- .../integration_test/image_picker_test.dart | 338 ------------------ .../old_image_picker_test.dart | 11 + packages/image_picker/example/lib/main.dart | 171 ++++----- packages/image_picker/example/pubspec.yaml | 15 +- .../example/test_driver/integration_test.dart | 2 + packages/image_picker/pubspec.yaml | 13 +- packages/integration_test/CHANGELOG.md | 10 +- packages/integration_test/LICENSE | 2 +- packages/integration_test/README.md | 11 +- packages/integration_test/example/README.md | 2 +- .../integration_test/_example_test_io.dart | 41 --- .../integration_test/_example_test_web.dart | 35 -- .../integration_test/_extended_test_io.dart | 38 -- .../integration_test/_extended_test_web.dart | 52 --- .../integration_test/example_test.dart | 39 +- .../integration_test/extended_test.dart | 19 - .../integration_test/example/lib/main.dart | 32 +- .../integration_test/example/lib/my_app.dart | 27 -- .../example/lib/my_web_app.dart | 28 -- .../integration_test/example/pubspec.yaml | 14 +- .../extended_integration_test.dart | 12 - .../example/test_driver/failure.dart | 45 --- .../example/test_driver/failure_test.dart | 20 -- .../example/test_driver/integration_test.dart | 2 + packages/integration_test/pubspec.yaml | 13 +- packages/package_info/CHANGELOG.md | 7 + packages/package_info/LICENSE | 2 +- packages/package_info/README.md | 6 +- .../integration_test/package_info_test.dart | 5 +- packages/package_info/example/lib/main.dart | 9 +- packages/package_info/example/pubspec.yaml | 14 +- .../example/test_driver/integration_test.dart | 2 + packages/package_info/pubspec.yaml | 12 +- packages/path_provider/CHANGELOG.md | 15 +- packages/path_provider/LICENSE | 2 +- packages/path_provider/README.md | 4 +- .../integration_test/path_provider_test.dart | 12 +- packages/path_provider/example/lib/main.dart | 113 +++--- packages/path_provider/example/pubspec.yaml | 17 +- .../example/test_driver/integration_test.dart | 2 + .../lib/path_provider_tizen.dart | 43 +-- .../path_provider/lib/src/app_common.dart | 63 ++-- packages/path_provider/lib/src/storage.dart | 34 +- packages/path_provider/pubspec.yaml | 14 +- packages/sensors/CHANGELOG.md | 9 +- packages/sensors/LICENSE | 2 +- packages/sensors/README.md | 4 +- packages/sensors/example/README.md | 2 +- .../integration_test/sensors_test.dart | 4 +- packages/sensors/example/lib/main.dart | 31 +- packages/sensors/example/lib/snake.dart | 47 +-- packages/sensors/example/pubspec.yaml | 11 +- .../example/test_driver/integration_test.dart | 2 + packages/sensors/pubspec.yaml | 15 +- packages/share/CHANGELOG.md | 9 + packages/share/LICENSE | 2 +- packages/share/README.md | 8 +- packages/share/example/README.md | 2 +- .../example/integration_test/share_test.dart | 6 +- .../share/example/lib/image_previews.dart | 14 +- packages/share/example/lib/main.dart | 27 +- packages/share/example/pubspec.yaml | 19 +- .../example/test_driver/integration_test.dart | 2 + packages/share/pubspec.yaml | 11 +- .../share/tizen/src/share_tizen_plugin.cc | 2 +- packages/shared_preferences/CHANGELOG.md | 15 +- packages/shared_preferences/LICENSE | 2 +- packages/shared_preferences/README.md | 4 +- .../shared_preferences_test.dart | 62 ++-- .../shared_preferences/example/lib/main.dart | 6 +- .../shared_preferences/example/pubspec.yaml | 11 +- .../example/test_driver/integration_test.dart | 2 + .../lib/shared_preferences_tizen.dart | 49 +-- .../shared_preferences/lib/src/bindings.dart | 32 +- .../shared_preferences/lib/src/types.dart | 9 +- packages/shared_preferences/pubspec.yaml | 14 +- packages/url_launcher/CHANGELOG.md | 10 + packages/url_launcher/LICENSE | 2 +- packages/url_launcher/README.md | 4 +- .../integration_test/url_launcher_test.dart | 7 +- packages/url_launcher/example/lib/main.dart | 22 +- packages/url_launcher/example/pubspec.yaml | 15 +- .../example/test_driver/integration_test.dart | 2 + .../url_launcher/lib/src/app_control.dart | 93 ++--- .../url_launcher/lib/url_launcher_tizen.dart | 38 +- packages/url_launcher/pubspec.yaml | 18 +- packages/wifi_info_flutter/CHANGELOG.md | 8 + packages/wifi_info_flutter/LICENSE | 2 +- packages/wifi_info_flutter/README.md | 4 +- packages/wifi_info_flutter/example/README.md | 2 +- .../integration_test/wifi_info_test.dart | 6 +- .../wifi_info_flutter/example/lib/main.dart | 20 +- .../wifi_info_flutter/example/pubspec.yaml | 16 +- .../example/test_driver/integration_test.dart | 2 + packages/wifi_info_flutter/pubspec.yaml | 13 +- 128 files changed, 1058 insertions(+), 1431 deletions(-) delete mode 100644 packages/image_picker/example/integration_test/image_picker_test.dart create mode 100644 packages/image_picker/example/integration_test/old_image_picker_test.dart delete mode 100644 packages/integration_test/example/integration_test/_example_test_io.dart delete mode 100644 packages/integration_test/example/integration_test/_example_test_web.dart delete mode 100644 packages/integration_test/example/integration_test/_extended_test_io.dart delete mode 100644 packages/integration_test/example/integration_test/_extended_test_web.dart delete mode 100644 packages/integration_test/example/integration_test/extended_test.dart delete mode 100644 packages/integration_test/example/lib/my_app.dart delete mode 100644 packages/integration_test/example/lib/my_web_app.dart delete mode 100644 packages/integration_test/example/test_driver/extended_integration_test.dart delete mode 100644 packages/integration_test/example/test_driver/failure.dart delete mode 100644 packages/integration_test/example/test_driver/failure_test.dart rename packages/sensors/{ => example}/integration_test/sensors_test.dart (91%) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 03cf07dbe..021d80ff6 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -13,12 +13,12 @@ jobs: - uses: actions/checkout@v2 - uses: subosito/flutter-action@v1 with: - flutter-version: "1.22.0" + flutter-version: "2.0.1" - name: Install pub dependencies run: | for d in `pwd`/packages/*/; do cd $d - flutter pub downgrade + flutter pub get done - name: Verify formatting run: flutter format --set-exit-if-changed packages diff --git a/README.md b/README.md index 3cb21b9a1..0b16e3993 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The _"non-endorsed"_ status means that the plugin is not endorsed by the origina | [**connectivity_tizen**](packages/connectivity) | [connectivity](https://github.com/flutter/plugins/tree/master/packages/connectivity) (1st-party) | [![pub package](https://img.shields.io/pub/v/connectivity_tizen.svg)](https://pub.dev/packages/connectivity_tizen) | No | | [**device_info_tizen**](packages/device_info) | [device_info](https://github.com/flutter/plugins/tree/master/packages/device_info) (1st-party) | [![pub package](https://img.shields.io/pub/v/device_info_tizen.svg)](https://pub.dev/packages/device_info_tizen) | No | | [**image_picker_tizen**](packages/image_picker) | [image_picker](https://github.com/flutter/plugins/tree/master/packages/image_picker) (1st-party) | [![pub package](https://img.shields.io/pub/v/image_picker_tizen.svg)](https://pub.dev/packages/image_picker_tizen) | No | -| [**integration_test_tizen**](packages/integration_test) | [integration_test](https://github.com/flutter/plugins/tree/master/packages/integration_test) (1st-party) | [![pub package](https://img.shields.io/pub/v/integration_test_tizen.svg)](https://pub.dev/packages/integration_test_tizen) | No | +| [**integration_test_tizen**](packages/integration_test) | [integration_test](https://github.com/flutter/flutter/tree/master/packages/integration_test) (1st-party) | [![pub package](https://img.shields.io/pub/v/integration_test_tizen.svg)](https://pub.dev/packages/integration_test_tizen) | No | | [**package_info_tizen**](packages/package_info) | [package_info](https://github.com/flutter/plugins/tree/master/packages/package_info) (1st-party) | [![pub package](https://img.shields.io/pub/v/package_info_tizen.svg)](https://pub.dev/packages/package_info_tizen) | No | | [**path_provider_tizen**](packages/path_provider) | [path_provider](https://github.com/flutter/plugins/tree/master/packages/path_provider) (1st-party) | [![pub package](https://img.shields.io/pub/v/path_provider_tizen.svg)](https://pub.dev/packages/path_provider_tizen) | No | | [**sensors_tizen**](packages/sensors) | [sensors](https://github.com/flutter/plugins/tree/master/packages/sensors) (1st-party) | [![pub package](https://img.shields.io/pub/v/sensors_tizen.svg)](https://pub.dev/packages/sensors_tizen) | No | diff --git a/packages/battery/CHANGELOG.md b/packages/battery/CHANGELOG.md index 6b7bfd2ad..eab91f23c 100644 --- a/packages/battery/CHANGELOG.md +++ b/packages/battery/CHANGELOG.md @@ -5,3 +5,11 @@ ## 1.0.1 * Port to use platform interface + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Update platform interface to 2.0.1 +* Organize dev_dependencies diff --git a/packages/battery/LICENSE b/packages/battery/LICENSE index 4e5cfe14e..5eee0ec43 100644 --- a/packages/battery/LICENSE +++ b/packages/battery/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2017 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/battery/README.md b/packages/battery/README.md index 046f1bf7c..5b73979d2 100644 --- a/packages/battery/README.md +++ b/packages/battery/README.md @@ -8,8 +8,8 @@ This package is not an _endorsed_ implementation of `battery`. Therefore, you ha ```yaml dependencies: - battery: ^1.0.11 - battery_tizen: ^1.0.1 + battery: ^2.0.1 + battery_tizen: ^2.0.0 ``` Then you can import `battery` in your Dart code: diff --git a/packages/battery/example/integration_test/battery_test.dart b/packages/battery/example/integration_test/battery_test.dart index ed7b6fe5a..24f5a5adc 100644 --- a/packages/battery/example/integration_test/battery_test.dart +++ b/packages/battery/example/integration_test/battery_test.dart @@ -1,6 +1,8 @@ -// Copyright 2019, the Chromium project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// @dart = 2.9 import 'package:flutter_test/flutter_test.dart'; import 'package:battery/battery.dart'; diff --git a/packages/battery/example/lib/main.dart b/packages/battery/example/lib/main.dart index eb01470d3..88f38e230 100644 --- a/packages/battery/example/lib/main.dart +++ b/packages/battery/example/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,13 +21,13 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(title: 'Flutter Demo Home Page'), + home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @@ -36,10 +36,10 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - Battery _battery = Battery(); + final Battery _battery = Battery(); - BatteryState _batteryState; - StreamSubscription _batteryStateSubscription; + BatteryState? _batteryState; + late StreamSubscription _batteryStateSubscription; @override void initState() { @@ -71,7 +71,7 @@ class _MyHomePageState extends State { builder: (_) => AlertDialog( content: Text('Battery: $batteryLevel%'), actions: [ - FlatButton( + TextButton( child: const Text('OK'), onPressed: () { Navigator.pop(context); @@ -82,7 +82,6 @@ class _MyHomePageState extends State { ); }, ), - floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, ); } diff --git a/packages/battery/example/pubspec.yaml b/packages/battery/example/pubspec.yaml index 730c59612..c024c9a5e 100644 --- a/packages/battery/example/pubspec.yaml +++ b/packages/battery/example/pubspec.yaml @@ -3,16 +3,19 @@ description: Demonstrates how to use the battery_tizen plugin. publish_to: 'none' dependencies: - flutter: - sdk: flutter - battery: ^1.0.11 + battery: ^2.0.1 battery_tizen: path: ../ + flutter: + sdk: flutter dev_dependencies: flutter_driver: sdk: flutter - integration_test: ^1.0.1 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter integration_test_tizen: path: ../../integration_test/ @@ -20,5 +23,5 @@ flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/battery/example/test_driver/integration_test.dart b/packages/battery/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/battery/example/test_driver/integration_test.dart +++ b/packages/battery/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/battery/pubspec.yaml b/packages/battery/pubspec.yaml index 1e904116a..9184d31a8 100644 --- a/packages/battery/pubspec.yaml +++ b/packages/battery/pubspec.yaml @@ -1,7 +1,7 @@ name: battery_tizen description: Flutter plugin for accessing information about the battery state (full, charging, discharging) on Tizen. -version: 1.0.1 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -12,14 +12,10 @@ flutter: fileName: battery_tizen_plugin.h dependencies: + battery_platform_interface: ^2.0.1 flutter: sdk: flutter - battery_platform_interface: ^1.0.0 - -dev_dependencies: - flutter_test: - sdk: flutter environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/connectivity/CHANGELOG.md b/packages/connectivity/CHANGELOG.md index 4fee7f4a6..31695f7ab 100644 --- a/packages/connectivity/CHANGELOG.md +++ b/packages/connectivity/CHANGELOG.md @@ -1,3 +1,12 @@ ## 1.0.0 -* Initial release \ No newline at end of file +* Initial release + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Update platform interface to 2.0.1 +* Organize dev_dependencies +* Replace pointer-based `Success()` with reference-based version diff --git a/packages/connectivity/LICENSE b/packages/connectivity/LICENSE index 934dd180c..29b9b9d1e 100644 --- a/packages/connectivity/LICENSE +++ b/packages/connectivity/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2017 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/connectivity/README.md b/packages/connectivity/README.md index b92ef0812..5c0ea9eed 100644 --- a/packages/connectivity/README.md +++ b/packages/connectivity/README.md @@ -8,9 +8,10 @@ This package is not an _endorsed_ implementation of `connectivity`. Therefore, y ```yaml dependencies: - connectivity: ^2.0.2 - connectivity_tizen: ^1.0.0 + connectivity: ^3.0.3 + connectivity_tizen: ^2.0.0 ``` + Then you can import `connectivity` in your Dart code: ```dart diff --git a/packages/connectivity/example/README.md b/packages/connectivity/example/README.md index 885d1a356..e9dc0cd73 100644 --- a/packages/connectivity/example/README.md +++ b/packages/connectivity/example/README.md @@ -1,6 +1,6 @@ -# connectiviy example +# connectiviy_example -Demonstrates how to use the connectiviy plugin. +Demonstrates how to use the connectiviy_tizen plugin. ## Getting Started diff --git a/packages/connectivity/example/integration_test/connectivity_test.dart b/packages/connectivity/example/integration_test/connectivity_test.dart index d48deae34..454ddd4c3 100644 --- a/packages/connectivity/example/integration_test/connectivity_test.dart +++ b/packages/connectivity/example/integration_test/connectivity_test.dart @@ -1,7 +1,10 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(cyanglaz): Remove once https://github.com/flutter/plugins/pull/3158 is landed. +// @dart = 2.9 + import 'package:integration_test/integration_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:connectivity/connectivity.dart'; diff --git a/packages/connectivity/example/lib/main.dart b/packages/connectivity/example/lib/main.dart index e05497136..0fe032e46 100644 --- a/packages/connectivity/example/lib/main.dart +++ b/packages/connectivity/example/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -34,13 +34,13 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(title: 'Flutter Demo Home Page'), + home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @@ -51,7 +51,7 @@ class MyHomePage extends StatefulWidget { class _MyHomePageState extends State { String _connectionStatus = 'Unknown'; final Connectivity _connectivity = Connectivity(); - StreamSubscription _connectivitySubscription; + late StreamSubscription _connectivitySubscription; @override void initState() { @@ -69,7 +69,7 @@ class _MyHomePageState extends State { // Platform messages are asynchronous, so we initialize in an async method. Future initConnectivity() async { - ConnectivityResult result; + ConnectivityResult result = ConnectivityResult.none; // Platform messages may fail, so we use a try/catch PlatformException. try { result = await _connectivity.checkConnectivity(); @@ -81,7 +81,7 @@ class _MyHomePageState extends State { // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) { - return Future.value(null); + return; } return _updateConnectionStatus(result); diff --git a/packages/connectivity/example/pubspec.yaml b/packages/connectivity/example/pubspec.yaml index 289dedfc9..23f2cda1d 100644 --- a/packages/connectivity/example/pubspec.yaml +++ b/packages/connectivity/example/pubspec.yaml @@ -1,19 +1,21 @@ name: connectivity_example -description: Demonstrates how to use the connectivity plugin. +description: Demonstrates how to use the connectivity_tizen plugin. publish_to: 'none' dependencies: - flutter: - sdk: flutter - connectivity: ^2.0.2 + connectivity: ^3.0.3 connectivity_tizen: path: ../ + flutter: + sdk: flutter dev_dependencies: flutter_driver: sdk: flutter - test: any - integration_test: ^1.0.1 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter integration_test_tizen: path: ../../integration_test/ @@ -21,5 +23,5 @@ flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/connectivity/example/test_driver/integration_test.dart b/packages/connectivity/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/connectivity/example/test_driver/integration_test.dart +++ b/packages/connectivity/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/connectivity/pubspec.yaml b/packages/connectivity/pubspec.yaml index 83c07011a..ae9473cab 100644 --- a/packages/connectivity/pubspec.yaml +++ b/packages/connectivity/pubspec.yaml @@ -1,6 +1,6 @@ name: connectivity_tizen description: Flutter plugin for discovering the state of the network (WiFi) connectivity on Tizen. -version: 1.0.0 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -9,20 +9,12 @@ flutter: tizen: pluginClass: ConnectivityTizenPlugin fileName: connectivity_tizen_plugin.h + dependencies: - connectivity: ^2.0.2 - connectivity_platform_interface: ^1.0.6 + connectivity_platform_interface: ^2.0.1 flutter: sdk: flutter -dev_dependencies: - test: any - flutter_driver: - sdk: flutter - flutter_test: - sdk: flutter - mockito: ^4.1.1 - environment: - sdk: ">=2.6.0 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/connectivity/tizen/src/connectivity_tizen_plugin.cc b/packages/connectivity/tizen/src/connectivity_tizen_plugin.cc index 0eb771d19..38582d177 100644 --- a/packages/connectivity/tizen/src/connectivity_tizen_plugin.cc +++ b/packages/connectivity/tizen/src/connectivity_tizen_plugin.cc @@ -91,7 +91,7 @@ class ConnectivityTizenPlugin : public flutter::Plugin { if (m_events == nullptr) return; std::string replay = convertConnectionTypeToString(state); flutter::EncodableValue msg(replay); - m_events->Success(&msg); + m_events->Success(msg); } private: @@ -150,7 +150,7 @@ class ConnectivityTizenPlugin : public flutter::Plugin { } flutter::EncodableValue msg(replay); - result->Success(&msg); + result->Success(msg); } connection_h m_connection; std::unique_ptr> m_events; diff --git a/packages/device_info/CHANGELOG.md b/packages/device_info/CHANGELOG.md index 4fee7f4a6..e8fa47f43 100644 --- a/packages/device_info/CHANGELOG.md +++ b/packages/device_info/CHANGELOG.md @@ -1,3 +1,14 @@ ## 1.0.0 -* Initial release \ No newline at end of file +* Initial release + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Update platform interface to 2.0.1 +* Organize dev_dependencies +* Migrate to null safety +* Add missing documentation +* Resolve the visibility warning (`channel` is visible for testing purposes only) diff --git a/packages/device_info/LICENSE b/packages/device_info/LICENSE index 934dd180c..29b9b9d1e 100644 --- a/packages/device_info/LICENSE +++ b/packages/device_info/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2017 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/device_info/README.md b/packages/device_info/README.md index 49b863563..89b48d90c 100644 --- a/packages/device_info/README.md +++ b/packages/device_info/README.md @@ -6,7 +6,7 @@ The Tizen implementation of [`device_info`](https://github.com/flutter/plugins/t ```yaml dependencies: - device_info_tizen: ^1.0.0 + device_info_tizen: ^2.0.0 ``` You can import `device_info_tizen` in your Dart code: diff --git a/packages/device_info/example/integration_test/device_info_test.dart b/packages/device_info/example/integration_test/device_info_test.dart index 8dda3203b..2a8555a36 100644 --- a/packages/device_info/example/integration_test/device_info_test.dart +++ b/packages/device_info/example/integration_test/device_info_test.dart @@ -1,11 +1,10 @@ -// Copyright 2019, the Chromium project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. // TODO(cyanglaz): Remove once https://github.com/flutter/plugins/pull/3158 is landed. // @dart = 2.9 -import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:device_info_tizen/device_info_tizen.dart'; import 'package:integration_test/integration_test.dart'; @@ -19,7 +18,7 @@ void main() { tizenInfo = await deviceInfo.tizenInfo; }); - testWidgets('Can get non-null device modelName', (WidgetTester tester) async { + testWidgets('Can get non-null device model', (WidgetTester tester) async { expect(tizenInfo.modelName, isNotNull); }); } diff --git a/packages/device_info/example/lib/main.dart b/packages/device_info/example/lib/main.dart index afb7dd02e..e03deea7b 100644 --- a/packages/device_info/example/lib/main.dart +++ b/packages/device_info/example/lib/main.dart @@ -1,5 +1,5 @@ // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,15 +7,14 @@ import 'dart:async'; -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:device_info_tizen/device_info_tizen.dart'; void main() { - runZoned(() { + runZonedGuarded(() { runApp(MyApp()); - }, onError: (dynamic error, dynamic stack) { + }, (dynamic error, dynamic stack) { print(error); print(stack); }); @@ -37,7 +36,7 @@ class _MyAppState extends State { } Future initPlatformState() async { - Map deviceData; + Map deviceData = {}; try { deviceData = _readTizenDeviceInfo(await deviceInfoPlugin.tizenInfo); @@ -47,7 +46,9 @@ class _MyAppState extends State { }; } - if (!mounted) return; + if (!mounted) { + return; + } setState(() { _deviceData = deviceData; @@ -77,7 +78,7 @@ class _MyAppState extends State { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - appBar: AppBar(title: Text('Tizen Device Info')), + appBar: AppBar(title: const Text('Tizen Device Info')), body: ListView( children: _deviceData.keys.map((String property) { return Row( diff --git a/packages/device_info/example/pubspec.yaml b/packages/device_info/example/pubspec.yaml index 4d43e21a9..76dbd8164 100644 --- a/packages/device_info/example/pubspec.yaml +++ b/packages/device_info/example/pubspec.yaml @@ -3,15 +3,18 @@ description: Demonstrates how to use the device_info_tizen plugin. publish_to: 'none' dependencies: - flutter: - sdk: flutter device_info_tizen: path: ../ + flutter: + sdk: flutter dev_dependencies: flutter_driver: sdk: flutter - integration_test: ^1.0.1 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter integration_test_tizen: path: ../../integration_test/ @@ -19,5 +22,5 @@ flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/device_info/example/test_driver/integration_test.dart b/packages/device_info/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/device_info/example/test_driver/integration_test.dart +++ b/packages/device_info/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/device_info/lib/device_info_tizen.dart b/packages/device_info/lib/device_info_tizen.dart index 60d6147db..b1a6bd532 100644 --- a/packages/device_info/lib/device_info_tizen.dart +++ b/packages/device_info/lib/device_info_tizen.dart @@ -1,93 +1,154 @@ // Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'dart:async'; + import 'package:device_info_platform_interface/device_info_platform_interface.dart'; -import 'package:device_info_platform_interface/method_channel/method_channel_device_info.dart'; +import 'package:flutter/services.dart'; -// model +/// Information derived from `system_info`. +/// +/// See: https://docs.tizen.org/application/native/guides/device/system class TizenDeviceInfo { - TizenDeviceInfo( - {this.modelName, - this.cpuArch, - this.nativeApiVersion, - this.platformVersion, - this.webApiVersion, - this.buildDate, - this.buildId, - this.buildString, - this.buildTime, - this.buildType, - this.buildVariant, - this.buildRelease, - this.deviceType, - this.manufacturer}); + /// Tizen device info class. + TizenDeviceInfo({ + required this.modelName, + required this.cpuArch, + required this.nativeApiVersion, + required this.platformVersion, + required this.webApiVersion, + required this.buildDate, + required this.buildId, + required this.buildString, + required this.buildTime, + required this.buildType, + required this.buildVariant, + required this.buildRelease, + required this.deviceType, + required this.manufacturer, + }); + /// http://tizen.org/system/model_name + /// + /// The value is an empty String if it is not available. final String modelName; + + /// http://tizen.org/feature/platform.core.cpu.arch + /// + /// The value is an empty String if it is not available. final String cpuArch; + + /// http://tizen.org/feature/platform.native.api.version + /// + /// The value is an empty String if it is not available. final String nativeApiVersion; + + /// http://tizen.org/feature/platform.version + /// + /// The value is an empty String if it is not available. final String platformVersion; + + /// http://tizen.org/feature/platform.web.api.version + /// + /// The value is an empty String if it is not available. final String webApiVersion; + + /// http://tizen.org/system/build.date + /// + /// The value is an empty String if it is not available. final String buildDate; + + /// http://tizen.org/system/build.id + /// + /// The value is an empty String if it is not available. final String buildId; + + /// http://tizen.org/system/build.string + /// + /// The value is an empty String if it is not available. final String buildString; + + /// http://tizen.org/system/build.time + /// + /// The value is an empty String if it is not available. final String buildTime; + + /// http://tizen.org/system/build.type + /// + /// The value is an empty String if it is not available. final String buildType; + + /// http://tizen.org/system/build.variant + /// + /// The value is an empty String if it is not available. final String buildVariant; + + /// http://tizen.org/system/build.release + /// + /// The value is an empty String if it is not available. final String buildRelease; + + /// http://tizen.org/system/device_type + /// + /// The value is an empty String if it is not available. final String deviceType; + + /// http://tizen.org/system/manufacturer + /// + /// The value is an empty String if it is not available. final String manufacturer; /// Deserializes from the message received from [_kChannel]. static TizenDeviceInfo fromMap(Map map) { return TizenDeviceInfo( - modelName: map['modelName'], - cpuArch: map['cpuArch'], - nativeApiVersion: map['nativeApiVersion'], - platformVersion: map['platformVersion'], - webApiVersion: map['webApiVersion'], - buildDate: map['buildDate'], - buildId: map['buildId'], - buildString: map['buildString'], - buildTime: map['buildTime'], - buildType: map['buildType'], - buildVariant: map['buildVariant'], - buildRelease: map['buildRelease'], - deviceType: map['deviceType'], - manufacturer: map['manufacturer'], + modelName: map['modelName'] as String? ?? '', + cpuArch: map['cpuArch'] as String? ?? '', + nativeApiVersion: map['nativeApiVersion'] as String? ?? '', + platformVersion: map['platformVersion'] as String? ?? '', + webApiVersion: map['webApiVersion'] as String? ?? '', + buildDate: map['buildDate'] as String? ?? '', + buildId: map['buildId'] as String? ?? '', + buildString: map['buildString'] as String? ?? '', + buildTime: map['buildTime'] as String? ?? '', + buildType: map['buildType'] as String? ?? '', + buildVariant: map['buildVariant'] as String? ?? '', + buildRelease: map['buildRelease'] as String? ?? '', + deviceType: map['deviceType'] as String? ?? '', + manufacturer: map['manufacturer'] as String? ?? '', ); } - - /// Deserializes message as List - static List _fromList(dynamic message) { - final List list = message; - return List.from(list); - } } -// method_channel /// An implementation of [DeviceInfoPlatform] that uses method channels. -class MethodChannelDeviceInfoTizen extends MethodChannelDeviceInfo { - // Method channel for Tizen devices +class MethodChannelDeviceInfoTizen extends DeviceInfoPlatform { + /// The method channel used to interact with the native platform. + MethodChannel channel = const MethodChannel('plugins.flutter.io/device_info'); + + /// Method channel for Tizen devices Future tizenInfo() async { - return TizenDeviceInfo.fromMap( - (await channel.invokeMethod('getTizenDeviceInfo')) - .cast(), - ); + return TizenDeviceInfo.fromMap((await channel + .invokeMapMethod('getTizenDeviceInfo')) ?? + {}); } } +/// Provides device and operating system information of a Tizen device. class DeviceInfoPluginTizen { - static MethodChannelDeviceInfoTizen _tizenInstance = - MethodChannelDeviceInfoTizen(); - + /// No work is done when instantiating the plugin. It's safe to call this + /// repeatedly or in performance-sensitive blocks. DeviceInfoPluginTizen(); + static final MethodChannelDeviceInfoTizen _tizenInstance = + MethodChannelDeviceInfoTizen(); + /// This information does not change from call to call. Cache it. - TizenDeviceInfo _cachedTizenDeviceInfo; + TizenDeviceInfo? _cachedTizenDeviceInfo; + /// Information derived from `system_info`. + /// + /// See: https://docs.tizen.org/application/native/guides/device/system Future get tizenInfo async => _cachedTizenDeviceInfo ??= await _tizenInstance.tizenInfo(); } diff --git a/packages/device_info/pubspec.yaml b/packages/device_info/pubspec.yaml index a12287288..7d3a424dc 100644 --- a/packages/device_info/pubspec.yaml +++ b/packages/device_info/pubspec.yaml @@ -1,7 +1,7 @@ name: device_info_tizen description: Flutter plugin providing detailed information about Tizen device (make, model, etc.). -version: 1.0.0 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -12,15 +12,10 @@ flutter: fileName: device_info_tizen_plugin.h dependencies: + device_info_platform_interface: ^2.0.1 flutter: sdk: flutter - device_info_platform_interface: ^1.0.0 - -dev_dependencies: - test: ^1.3.0 - flutter_test: - sdk: flutter environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: '>=2.12.0 <3.0.0' + flutter: ">=2.0.0" diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index 32f490b5f..92f6832b2 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -1,3 +1,12 @@ ## 1.0.0 * Initial release + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Port to use platform interface +* Update video_player to 2.0.2 +* Organize dev_dependencies diff --git a/packages/image_picker/LICENSE b/packages/image_picker/LICENSE index e608d6e8d..29b9b9d1e 100644 --- a/packages/image_picker/LICENSE +++ b/packages/image_picker/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2019 The Flutter Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/image_picker/README.md b/packages/image_picker/README.md index 9e8a132f7..42cb4f516 100644 --- a/packages/image_picker/README.md +++ b/packages/image_picker/README.md @@ -6,6 +6,12 @@ The Tizen implementation of [`image_picker`](https://github.com/flutter/plugins/ To use this plugin, add `image_picker` and `image_picker_tizen` as [dependencies in your pubspec.yaml file](https://flutter.io/platform-plugins/). +```yaml +dependencies: + image_picker: ^0.7.3 + image_picker_tizen: ^2.0.0 +``` + ## Example Import the library. @@ -28,7 +34,7 @@ final pickedFile = await picker.getImage(source: ImageSource.gallery); ## Required privileges -To use this plugin, you need to declare privileges in tizen-manifest.xml of your application. +To use this plugin, you need to declare privileges in `tizen-manifest.xml` of your application. ``` xml diff --git a/packages/image_picker/example/README.md b/packages/image_picker/example/README.md index 2314160e3..625c6e7b2 100644 --- a/packages/image_picker/example/README.md +++ b/packages/image_picker/example/README.md @@ -1,3 +1,3 @@ -# image_picker_tizen example +# image_picker_tizen_example Demonstrates how to use the image_picker_tizen plugin. diff --git a/packages/image_picker/example/integration_test/image_picker_test.dart b/packages/image_picker/example/integration_test/image_picker_test.dart deleted file mode 100644 index 0ada1b261..000000000 --- a/packages/image_picker/example/integration_test/image_picker_test.dart +++ /dev/null @@ -1,338 +0,0 @@ -// Copyright 2019 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:image_picker/image_picker.dart'; - -void main() { - TestWidgetsFlutterBinding.ensureInitialized(); - - group('$ImagePicker', () { - const MethodChannel channel = - MethodChannel('plugins.flutter.io/image_picker'); - - final List log = []; - - final picker = ImagePicker(); - - setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - log.add(methodCall); - return ''; - }); - - log.clear(); - }); - - group('#pickImage', () { - test('passes the image source argument correctly', () async { - await picker.getImage(source: ImageSource.camera); - await picker.getImage(source: ImageSource.gallery); - - expect( - log, - [ - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': null, - 'maxHeight': null, - 'imageQuality': null, - 'cameraDevice': 0 - }), - isMethodCall('pickImage', arguments: { - 'source': 1, - 'maxWidth': null, - 'maxHeight': null, - 'imageQuality': null, - 'cameraDevice': 0 - }), - ], - ); - }); - - test('passes the width and height arguments correctly', () async { - await picker.getImage(source: ImageSource.camera); - await picker.getImage( - source: ImageSource.camera, - maxWidth: 10.0, - ); - await picker.getImage( - source: ImageSource.camera, - maxHeight: 10.0, - ); - await picker.getImage( - source: ImageSource.camera, - maxWidth: 10.0, - maxHeight: 20.0, - ); - await picker.getImage( - source: ImageSource.camera, maxWidth: 10.0, imageQuality: 70); - await picker.getImage( - source: ImageSource.camera, maxHeight: 10.0, imageQuality: 70); - await picker.getImage( - source: ImageSource.camera, - maxWidth: 10.0, - maxHeight: 20.0, - imageQuality: 70); - - expect( - log, - [ - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': null, - 'maxHeight': null, - 'imageQuality': null, - 'cameraDevice': 0 - }), - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': 10.0, - 'maxHeight': null, - 'imageQuality': null, - 'cameraDevice': 0 - }), - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': null, - 'maxHeight': 10.0, - 'imageQuality': null, - 'cameraDevice': 0 - }), - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': 10.0, - 'maxHeight': 20.0, - 'imageQuality': null, - 'cameraDevice': 0 - }), - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': 10.0, - 'maxHeight': null, - 'imageQuality': 70, - 'cameraDevice': 0 - }), - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': null, - 'maxHeight': 10.0, - 'imageQuality': 70, - 'cameraDevice': 0 - }), - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': 10.0, - 'maxHeight': 20.0, - 'imageQuality': 70, - 'cameraDevice': 0 - }), - ], - ); - }); - - test('does not accept a negative width or height argument', () { - expect( - picker.getImage(source: ImageSource.camera, maxWidth: -1.0), - throwsArgumentError, - ); - - expect( - picker.getImage(source: ImageSource.camera, maxHeight: -1.0), - throwsArgumentError, - ); - }); - - test('handles a null image path response gracefully', () async { - channel.setMockMethodCallHandler((MethodCall methodCall) => null); - - expect(await picker.getImage(source: ImageSource.gallery), isNull); - expect(await picker.getImage(source: ImageSource.camera), isNull); - }); - - test('camera position defaults to back', () async { - await picker.getImage(source: ImageSource.camera); - - expect( - log, - [ - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': null, - 'maxHeight': null, - 'imageQuality': null, - 'cameraDevice': 0, - }), - ], - ); - }); - - test('camera position can set to front', () async { - await picker.getImage( - source: ImageSource.camera, - preferredCameraDevice: CameraDevice.front); - - expect( - log, - [ - isMethodCall('pickImage', arguments: { - 'source': 0, - 'maxWidth': null, - 'maxHeight': null, - 'imageQuality': null, - 'cameraDevice': 1, - }), - ], - ); - }); - }); - - group('#pickVideo', () { - test('passes the image source argument correctly', () async { - await picker.getVideo(source: ImageSource.camera); - await picker.getVideo(source: ImageSource.gallery); - - expect( - log, - [ - isMethodCall('pickVideo', arguments: { - 'source': 0, - 'cameraDevice': 0, - 'maxDuration': null, - }), - isMethodCall('pickVideo', arguments: { - 'source': 1, - 'cameraDevice': 0, - 'maxDuration': null, - }), - ], - ); - }); - - test('passes the duration argument correctly', () async { - await picker.getVideo(source: ImageSource.camera); - await picker.getVideo( - source: ImageSource.camera, - maxDuration: const Duration(seconds: 10)); - await picker.getVideo( - source: ImageSource.camera, - maxDuration: const Duration(minutes: 1)); - await picker.getVideo( - source: ImageSource.camera, maxDuration: const Duration(hours: 1)); - expect( - log, - [ - isMethodCall('pickVideo', arguments: { - 'source': 0, - 'maxDuration': null, - 'cameraDevice': 0, - }), - isMethodCall('pickVideo', arguments: { - 'source': 0, - 'maxDuration': 10, - 'cameraDevice': 0, - }), - isMethodCall('pickVideo', arguments: { - 'source': 0, - 'maxDuration': 60, - 'cameraDevice': 0, - }), - isMethodCall('pickVideo', arguments: { - 'source': 0, - 'maxDuration': 3600, - 'cameraDevice': 0, - }), - ], - ); - }); - - test('handles a null video path response gracefully', () async { - channel.setMockMethodCallHandler((MethodCall methodCall) => null); - - expect(await picker.getVideo(source: ImageSource.gallery), isNull); - expect(await picker.getVideo(source: ImageSource.camera), isNull); - }); - - test('camera position defaults to back', () async { - await picker.getVideo(source: ImageSource.camera); - - expect( - log, - [ - isMethodCall('pickVideo', arguments: { - 'source': 0, - 'cameraDevice': 0, - 'maxDuration': null, - }), - ], - ); - }); - - test('camera position can set to front', () async { - await picker.getVideo( - source: ImageSource.camera, - preferredCameraDevice: CameraDevice.front); - - expect( - log, - [ - isMethodCall('pickVideo', arguments: { - 'source': 0, - 'maxDuration': null, - 'cameraDevice': 1, - }), - ], - ); - }); - }); - - group('#retrieveLostData', () { - test('retrieveLostData get success response', () async { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - return { - 'type': 'image', - 'path': '/example/path', - }; - }); - final LostData response = await picker.getLostData(); - expect(response.type, RetrieveType.image); - expect(response.file.path, '/example/path'); - }); - - test('retrieveLostData get error response', () async { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - return { - 'type': 'video', - 'errorCode': 'test_error_code', - 'errorMessage': 'test_error_message', - }; - }); - final LostData response = await picker.getLostData(); - expect(response.type, RetrieveType.video); - expect(response.exception.code, 'test_error_code'); - expect(response.exception.message, 'test_error_message'); - }); - - test('retrieveLostData get null response', () async { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - return null; - }); - expect((await picker.getLostData()).isEmpty, true); - }); - - test('retrieveLostData get both path and error should throw', () async { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - return { - 'type': 'video', - 'errorCode': 'test_error_code', - 'errorMessage': 'test_error_message', - 'path': '/example/path', - }; - }); - expect(picker.getLostData(), throwsAssertionError); - }); - }); - }); -} diff --git a/packages/image_picker/example/integration_test/old_image_picker_test.dart b/packages/image_picker/example/integration_test/old_image_picker_test.dart new file mode 100644 index 000000000..528c8b9f1 --- /dev/null +++ b/packages/image_picker/example/integration_test/old_image_picker_test.dart @@ -0,0 +1,11 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// @dart=2.9 + +import 'package:integration_test/integration_test.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); +} diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index fca813bef..81cedc368 100644 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -1,5 +1,4 @@ -// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. -// Copyright 2019 The Flutter Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -10,8 +9,6 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/src/widgets/basic.dart'; -import 'package:flutter/src/widgets/container.dart'; import 'package:image_picker/image_picker.dart'; import 'package:video_player/video_player.dart'; @@ -22,7 +19,7 @@ void main() { class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( + return const MaterialApp( title: 'Image Picker Demo', home: MyHomePage(title: 'Image Picker Example'), ); @@ -30,62 +27,65 @@ class MyApp extends StatelessWidget { } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key? key, this.title}) : super(key: key); - final String title; + final String? title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { - PickedFile _imageFile; + PickedFile? _imageFile; dynamic _pickImageError; bool isVideo = false; - VideoPlayerController _controller; - VideoPlayerController _toBeDisposed; - String _retrieveDataError; + VideoPlayerController? _controller; + VideoPlayerController? _toBeDisposed; + String? _retrieveDataError; final ImagePicker _picker = ImagePicker(); final TextEditingController maxWidthController = TextEditingController(); final TextEditingController maxHeightController = TextEditingController(); final TextEditingController qualityController = TextEditingController(); - Future _playVideo(PickedFile file) async { + Future _playVideo(PickedFile? file) async { if (file != null && mounted) { await _disposeVideoController(); + late VideoPlayerController controller; if (kIsWeb) { - _controller = VideoPlayerController.network(file.path); - // In web, most browsers won't honor a programmatic call to .play - // if the video has a sound track (and is not muted). - // Mute the video so it auto-plays in web! - // This is not needed if the call to .play is the result of user - // interaction (clicking on a "play" button, for example). - await _controller.setVolume(0.0); + controller = VideoPlayerController.network(file.path); } else { - _controller = VideoPlayerController.file(File(file.path)); - await _controller.setVolume(1.0); + controller = VideoPlayerController.file(File(file.path)); } - await _controller.initialize(); - await _controller.setLooping(true); - await _controller.play(); + _controller = controller; + // In web, most browsers won't honor a programmatic call to .play + // if the video has a sound track (and is not muted). + // Mute the video so it auto-plays in web! + // This is not needed if the call to .play is the result of user + // interaction (clicking on a "play" button, for example). + final double volume = kIsWeb ? 0.0 : 1.0; + await controller.setVolume(volume); + await controller.initialize(); + await controller.setLooping(true); + await controller.play(); setState(() {}); } } - void _onImageButtonPressed(ImageSource source, {BuildContext context}) async { + Future _onImageButtonPressed(ImageSource source, + {BuildContext? context}) async { if (_controller != null) { - await _controller.setVolume(0.0); + await _controller!.setVolume(0.0); } if (isVideo) { - final PickedFile file = await _picker.getVideo( + final PickedFile? file = await _picker.getVideo( source: source, maxDuration: const Duration(seconds: 10)); await _playVideo(file); } else { - await _displayPickImageDialog(context, - (double maxWidth, double maxHeight, int quality) async { + await _displayPickImageDialog(context!, + (double? maxWidth, double? maxHeight, int? quality) async { try { - final pickedFile = await _picker.getImage( + final PickedFile? pickedFile = await _picker.getImage( source: source, maxWidth: maxWidth, maxHeight: maxHeight, @@ -106,8 +106,8 @@ class _MyHomePageState extends State { @override void deactivate() { if (_controller != null) { - _controller.setVolume(0.0); - _controller.pause(); + _controller!.setVolume(0.0); + _controller!.pause(); } super.deactivate(); } @@ -123,14 +123,14 @@ class _MyHomePageState extends State { Future _disposeVideoController() async { if (_toBeDisposed != null) { - await _toBeDisposed.dispose(); + await _toBeDisposed!.dispose(); } _toBeDisposed = _controller; _controller = null; } Widget _previewVideo() { - final Text retrieveError = _getRetrieveErrorWidget(); + final Text? retrieveError = _getRetrieveErrorWidget(); if (retrieveError != null) { return retrieveError; } @@ -147,7 +147,7 @@ class _MyHomePageState extends State { } Widget _previewImage() { - final Text retrieveError = _getRetrieveErrorWidget(); + final Text? retrieveError = _getRetrieveErrorWidget(); if (retrieveError != null) { return retrieveError; } @@ -155,9 +155,11 @@ class _MyHomePageState extends State { if (kIsWeb) { // Why network? // See https://pub.dev/packages/image_picker#getting-ready-for-the-web-platform - return Image.network(_imageFile.path); + return Image.network(_imageFile!.path); } else { - return Image.file(File(_imageFile.path)); + return Semantics( + child: Image.file(File(_imageFile!.path)), + label: 'image_picker_example_picked_image'); } } else if (_pickImageError != null) { return Text( @@ -188,7 +190,7 @@ class _MyHomePageState extends State { }); } } else { - _retrieveDataError = response.exception.code; + _retrieveDataError = response.exception!.code; } } @@ -196,7 +198,7 @@ class _MyHomePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(widget.title), + title: Text(widget.title!), ), body: Center( child: !kIsWeb && defaultTargetPlatform == TargetPlatform.android @@ -232,17 +234,20 @@ class _MyHomePageState extends State { floatingActionButton: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ - FloatingActionButton( - onPressed: () { - isVideo = false; - _onImageButtonPressed(ImageSource.gallery, context: context); - }, - heroTag: 'image0', - tooltip: 'Pick Image from gallery', - child: const Icon(Icons.photo_library), + Semantics( + label: 'image_picker_example_from_gallery', + child: FloatingActionButton( + onPressed: () { + isVideo = false; + _onImageButtonPressed(ImageSource.gallery, context: context); + }, + heroTag: 'image0', + tooltip: 'Pick Image from gallery', + child: const Icon(Icons.photo_library), + ), ), Padding( - padding: const EdgeInsets.only(top: 0.0), + padding: const EdgeInsets.only(top: 16.0), child: FloatingActionButton( onPressed: () { isVideo = false; @@ -254,7 +259,7 @@ class _MyHomePageState extends State { ), ), Padding( - padding: const EdgeInsets.only(top: 0.0), + padding: const EdgeInsets.only(top: 16.0), child: FloatingActionButton( backgroundColor: Colors.red, onPressed: () { @@ -267,7 +272,7 @@ class _MyHomePageState extends State { ), ), Padding( - padding: const EdgeInsets.only(top: 0.0), + padding: const EdgeInsets.only(top: 16.0), child: FloatingActionButton( backgroundColor: Colors.red, onPressed: () { @@ -284,9 +289,9 @@ class _MyHomePageState extends State { ); } - Text _getRetrieveErrorWidget() { + Text? _getRetrieveErrorWidget() { if (_retrieveDataError != null) { - final Text result = Text(_retrieveDataError); + final Text result = Text(_retrieveDataError!); _retrieveDataError = null; return result; } @@ -297,54 +302,50 @@ class _MyHomePageState extends State { BuildContext context, OnPickImageCallback onPick) async { return showDialog( context: context, - builder: (context) { + builder: (BuildContext context) { return AlertDialog( - title: Text('Add optional parameters'), - content: ListView( + title: const Text('Add optional parameters'), + content: Column( children: [ TextField( controller: maxWidthController, - keyboardType: TextInputType.numberWithOptions(decimal: true), - decoration: - InputDecoration(hintText: "Enter maxWidth if desired"), - ), - Padding( - padding: const EdgeInsets.all(6.0), + keyboardType: + const TextInputType.numberWithOptions(decimal: true), + decoration: const InputDecoration( + hintText: 'Enter maxWidth if desired'), ), TextField( controller: maxHeightController, - keyboardType: TextInputType.numberWithOptions(decimal: true), - decoration: - InputDecoration(hintText: "Enter maxHeight if desired"), - ), - Padding( - padding: const EdgeInsets.all(6.0), + keyboardType: + const TextInputType.numberWithOptions(decimal: true), + decoration: const InputDecoration( + hintText: 'Enter maxHeight if desired'), ), TextField( controller: qualityController, keyboardType: TextInputType.number, - decoration: - InputDecoration(hintText: "Enter quality if desired"), + decoration: const InputDecoration( + hintText: 'Enter quality if desired'), ), ], ), actions: [ - FlatButton( + TextButton( child: const Text('CANCEL'), onPressed: () { Navigator.of(context).pop(); }, ), - FlatButton( + TextButton( child: const Text('PICK'), onPressed: () { - double width = maxWidthController.text.isNotEmpty + final double? width = maxWidthController.text.isNotEmpty ? double.parse(maxWidthController.text) : null; - double height = maxHeightController.text.isNotEmpty + final double? height = maxHeightController.text.isNotEmpty ? double.parse(maxHeightController.text) : null; - int quality = qualityController.text.isNotEmpty + final int? quality = qualityController.text.isNotEmpty ? int.parse(qualityController.text) : null; onPick(width, height, quality); @@ -356,28 +357,28 @@ class _MyHomePageState extends State { } } -typedef void OnPickImageCallback( - double maxWidth, double maxHeight, int quality); +typedef OnPickImageCallback = void Function( + double? maxWidth, double? maxHeight, int? quality); class AspectRatioVideo extends StatefulWidget { - AspectRatioVideo(this.controller); + const AspectRatioVideo(this.controller); - final VideoPlayerController controller; + final VideoPlayerController? controller; @override AspectRatioVideoState createState() => AspectRatioVideoState(); } class AspectRatioVideoState extends State { - VideoPlayerController get controller => widget.controller; + VideoPlayerController? get controller => widget.controller; bool initialized = false; void _onVideoControllerUpdate() { if (!mounted) { return; } - if (initialized != controller.value.initialized) { - initialized = controller.value.initialized; + if (initialized != controller!.value.isInitialized) { + initialized = controller!.value.isInitialized; setState(() {}); } } @@ -385,12 +386,12 @@ class AspectRatioVideoState extends State { @override void initState() { super.initState(); - controller.addListener(_onVideoControllerUpdate); + controller!.addListener(_onVideoControllerUpdate); } @override void dispose() { - controller.removeListener(_onVideoControllerUpdate); + controller!.removeListener(_onVideoControllerUpdate); super.dispose(); } @@ -399,8 +400,8 @@ class AspectRatioVideoState extends State { if (initialized) { return Center( child: AspectRatio( - aspectRatio: controller.value?.aspectRatio, - child: VideoPlayer(controller), + aspectRatio: controller!.value.aspectRatio, + child: VideoPlayer(controller!), ), ); } else { diff --git a/packages/image_picker/example/pubspec.yaml b/packages/image_picker/example/pubspec.yaml index b1ea24a91..8fffb29a2 100644 --- a/packages/image_picker/example/pubspec.yaml +++ b/packages/image_picker/example/pubspec.yaml @@ -3,23 +3,26 @@ description: Demonstrates how to use the image_picker_tizen plugin. publish_to: 'none' dependencies: - video_player: ^0.10.3 flutter: sdk: flutter - image_picker: ^0.6.7 + image_picker: ^0.7.3 image_picker_tizen: path: ../ + video_player: ^2.0.2 dev_dependencies: flutter_driver: sdk: flutter - integration_test: ^0.9.2 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter integration_test_tizen: - path: ../../integration_test + path: ../../integration_test/ flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/image_picker/example/test_driver/integration_test.dart b/packages/image_picker/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/image_picker/example/test_driver/integration_test.dart +++ b/packages/image_picker/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index 4052797f7..f0997adbf 100644 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -1,7 +1,7 @@ name: image_picker_tizen description: Flutter plugin for selecting images from the Tizen image library, and taking new pictures with the camera. -version: 1.0.0 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -14,13 +14,8 @@ flutter: dependencies: flutter: sdk: flutter - -dev_dependencies: - video_player: ^0.10.3 - flutter_test: - sdk: flutter - image_picker: ^0.6.7 + image_picker_platform_interface: ^2.0.1 environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/integration_test/CHANGELOG.md b/packages/integration_test/CHANGELOG.md index e55337e42..f5a9dc35c 100644 --- a/packages/integration_test/CHANGELOG.md +++ b/packages/integration_test/CHANGELOG.md @@ -4,5 +4,13 @@ ## 1.0.1 -* Update integration_test to the latest (1.0.1) +* Update integration_test to 1.0.1 * Migrate to Tizen 4.0 + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Remove unnecessary test files for web +* Organize dev_dependencies diff --git a/packages/integration_test/LICENSE b/packages/integration_test/LICENSE index 7f6595961..5eee0ec43 100644 --- a/packages/integration_test/LICENSE +++ b/packages/integration_test/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2019 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/integration_test/README.md b/packages/integration_test/README.md index 1c400e211..582349b71 100644 --- a/packages/integration_test/README.md +++ b/packages/integration_test/README.md @@ -1,15 +1,16 @@ # integration_test_tizen -The Tizen implementation of [`integration_test`](https://github.com/flutter/plugins/tree/master/packages/integration_test). +The Tizen implementation of [`integration_test`](https://github.com/flutter/flutter/tree/master/packages/integration_test). ## Usage This package is not an _endorsed_ implementation of `integration_test`. Therefore, you have to include `integration_test_tizen` alongside `integration_test` as dependencies in your `pubspec.yaml` file. ```yaml -dependencies: - integration_test: ^1.0.1 - integration_test_tizen: ^1.0.1 +dev_dependencies: + integration_test: + sdk: flutter + integration_test_tizen: ^2.0.0 ``` Then you can import `integration_test` in your Dart code: @@ -18,4 +19,4 @@ Then you can import `integration_test` in your Dart code: import 'package:integration_test/integration_test.dart'; ``` -For detailed usage, see https://github.com/flutter/plugins/tree/master/packages/integration_test#usage. +For detailed usage, see https://github.com/flutter/flutter/tree/master/packages/integration_test#usage. diff --git a/packages/integration_test/example/README.md b/packages/integration_test/example/README.md index 3f63481eb..1ef69b0a5 100644 --- a/packages/integration_test/example/README.md +++ b/packages/integration_test/example/README.md @@ -2,7 +2,7 @@ Demonstrates how to use the integration_test_tizen plugin. -To run `integration_test/example_test.dart` with the [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen) tool, use the following command. +To run `integration_test/example_test.dart` on your Tizen device, ```sh flutter-tizen drive \ diff --git a/packages/integration_test/example/integration_test/_example_test_io.dart b/packages/integration_test/example/integration_test/_example_test_io.dart deleted file mode 100644 index 7ed28963c..000000000 --- a/packages/integration_test/example/integration_test/_example_test_io.dart +++ /dev/null @@ -1,41 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'dart:io' show Platform; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; - -import 'package:integration_test_example/main.dart' as app; - -void main() { - final IntegrationTestWidgetsFlutterBinding binding = - IntegrationTestWidgetsFlutterBinding.ensureInitialized() - as IntegrationTestWidgetsFlutterBinding; - testWidgets('verify text', (WidgetTester tester) async { - // Build our app and trigger a frame. - app.main(); - - // Trace the timeline of the following operation. The timeline result will - // be written to `build/integration_response_data.json` with the key - // `timeline`. - await binding.traceAction(() async { - // Trigger a frame. - await tester.pumpAndSettle(); - - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && - widget.data.startsWith('Platform: ${Platform.operatingSystem}'), - ), - findsOneWidget, - ); - }); - }); -} diff --git a/packages/integration_test/example/integration_test/_example_test_web.dart b/packages/integration_test/example/integration_test/_example_test_web.dart deleted file mode 100644 index e1141cc01..000000000 --- a/packages/integration_test/example/integration_test/_example_test_web.dart +++ /dev/null @@ -1,35 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'dart:html' as html; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; - -import 'package:integration_test_example/main.dart' as app; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - testWidgets('verify text', (WidgetTester tester) async { - // Build our app and trigger a frame. - app.main(); - - // Trigger a frame. - await tester.pumpAndSettle(); - - // Verify that platform is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && - widget.data - .startsWith('Platform: ${html.window.navigator.platform}\n'), - ), - findsOneWidget, - ); - }); -} diff --git a/packages/integration_test/example/integration_test/_extended_test_io.dart b/packages/integration_test/example/integration_test/_extended_test_io.dart deleted file mode 100644 index 56fee6f71..000000000 --- a/packages/integration_test/example/integration_test/_extended_test_io.dart +++ /dev/null @@ -1,38 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'dart:io' show Platform; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; - -import 'package:integration_test_example/main.dart' as app; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - testWidgets('verify text', (WidgetTester tester) async { - // Build our app and trigger a frame. - app.main(); - - // Trigger a frame. - await tester.pumpAndSettle(); - - // TODO: https://github.com/flutter/flutter/issues/51890 - // Add screenshot capability for mobile platforms. - - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && - widget.data.startsWith('Platform: ${Platform.operatingSystem}'), - ), - findsOneWidget, - ); - }); -} diff --git a/packages/integration_test/example/integration_test/_extended_test_web.dart b/packages/integration_test/example/integration_test/_extended_test_web.dart deleted file mode 100644 index 210c2dac7..000000000 --- a/packages/integration_test/example/integration_test/_extended_test_web.dart +++ /dev/null @@ -1,52 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'dart:html' as html; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; - -import 'package:integration_test_example/main.dart' as app; - -void main() { - final IntegrationTestWidgetsFlutterBinding binding = - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - testWidgets('verify text', (WidgetTester tester) async { - // Build our app and trigger a frame. - app.main(); - - // Trigger a frame. - await tester.pumpAndSettle(); - - // Take a screenshot. - await binding.takeScreenshot('platform_name'); - - // Verify that platform is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && - widget.data - .startsWith('Platform: ${html.window.navigator.platform}\n'), - ), - findsOneWidget, - ); - }); - - testWidgets('verify screenshot', (WidgetTester tester) async { - // Build our app and trigger a frame. - app.main(); - - // Trigger a frame. - await tester.pumpAndSettle(); - - // Multiple methods can take screenshots. Screenshots are taken with the - // same order the methods run. - await binding.takeScreenshot('platform_name_2'); - }); -} diff --git a/packages/integration_test/example/integration_test/example_test.dart b/packages/integration_test/example/integration_test/example_test.dart index 918aec877..1939e836c 100644 --- a/packages/integration_test/example/integration_test/example_test.dart +++ b/packages/integration_test/example/integration_test/example_test.dart @@ -1,3 +1,7 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + // This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester @@ -5,12 +9,39 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. +// @dart=2.9 + +import 'dart:io' show Platform; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; -import '_example_test_io.dart' if (dart.library.html) '_example_test_web.dart' - as tests; +import 'package:integration_test_example/main.dart' as app; void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - tests.main(); + final IntegrationTestWidgetsFlutterBinding binding = + IntegrationTestWidgetsFlutterBinding.ensureInitialized() + as IntegrationTestWidgetsFlutterBinding; + testWidgets('verify text', (WidgetTester tester) async { + // Build our app and trigger a frame. + app.main(); + + // Trace the timeline of the following operation. The timeline result will + // be written to `build/integration_response_data.json` with the key + // `timeline`. + await binding.traceAction(() async { + // Trigger a frame. + await tester.pumpAndSettle(); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => + widget is Text && + widget.data.startsWith('Platform: ${Platform.operatingSystem}'), + ), + findsOneWidget, + ); + }); + }); } diff --git a/packages/integration_test/example/integration_test/extended_test.dart b/packages/integration_test/example/integration_test/extended_test.dart deleted file mode 100644 index 23d69a8f9..000000000 --- a/packages/integration_test/example/integration_test/extended_test.dart +++ /dev/null @@ -1,19 +0,0 @@ -// This is a Flutter widget test can take a screenshot. -// -// NOTE: Screenshots are only supported on Web for now. For Web, this needs to -// be executed with the `test_driver/integration_test_extended_driver.dart`. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:integration_test/integration_test.dart'; - -import '_extended_test_io.dart' if (dart.library.html) '_extended_test_web.dart' - as tests; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - tests.main(); -} diff --git a/packages/integration_test/example/lib/main.dart b/packages/integration_test/example/lib/main.dart index 1f33324ac..709b01fe3 100644 --- a/packages/integration_test/example/lib/main.dart +++ b/packages/integration_test/example/lib/main.dart @@ -1,5 +1,33 @@ -import 'my_app.dart' if (dart.library.html) 'my_web_app.dart'; +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'dart:io' show Platform; +import 'package:flutter/material.dart'; // ignore_for_file: public_member_api_docs -void main() => startApp(); +void main() => runApp(const MyApp()); + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + _MyAppState createState() => _MyAppState(); +} + +class _MyAppState extends State { + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Platform: ${Platform.operatingSystem}\n'), + ), + ), + ); + } +} diff --git a/packages/integration_test/example/lib/my_app.dart b/packages/integration_test/example/lib/my_app.dart deleted file mode 100644 index bfbdb860c..000000000 --- a/packages/integration_test/example/lib/my_app.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'dart:io' show Platform; -import 'package:flutter/material.dart'; - -// ignore_for_file: public_member_api_docs - -void startApp() => runApp(MyApp()); - -class MyApp extends StatefulWidget { - @override - _MyAppState createState() => _MyAppState(); -} - -class _MyAppState extends State { - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Plugin example app'), - ), - body: Center( - child: Text('Platform: ${Platform.operatingSystem}\n'), - ), - ), - ); - } -} diff --git a/packages/integration_test/example/lib/my_web_app.dart b/packages/integration_test/example/lib/my_web_app.dart deleted file mode 100644 index c2ced1af9..000000000 --- a/packages/integration_test/example/lib/my_web_app.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'dart:html' as html; -import 'package:flutter/material.dart'; - -// ignore_for_file: public_member_api_docs - -void startApp() => runApp(MyWebApp()); - -class MyWebApp extends StatefulWidget { - @override - _MyWebAppState createState() => _MyWebAppState(); -} - -class _MyWebAppState extends State { - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - appBar: AppBar( - title: const Text('Plugin example app'), - ), - body: Center( - key: Key('mainapp'), - child: Text('Platform: ${html.window.navigator.platform}\n'), - ), - ), - ); - } -} diff --git a/packages/integration_test/example/pubspec.yaml b/packages/integration_test/example/pubspec.yaml index ba83bdca3..ea6eb6db7 100644 --- a/packages/integration_test/example/pubspec.yaml +++ b/packages/integration_test/example/pubspec.yaml @@ -1,25 +1,25 @@ name: integration_test_example -description: Demonstrates how to use the integration_test plugin. +description: Demonstrates how to use the integration_test_tizen plugin. publish_to: 'none' dependencies: flutter: sdk: flutter - cupertino_icons: ^0.1.2 dev_dependencies: + flutter_driver: + sdk: flutter flutter_test: sdk: flutter - flutter_driver: + integration_test: sdk: flutter - integration_test: ^1.0.1 integration_test_tizen: path: ../ - test: any + test: flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/integration_test/example/test_driver/extended_integration_test.dart b/packages/integration_test/example/test_driver/extended_integration_test.dart deleted file mode 100644 index 056ba4bad..000000000 --- a/packages/integration_test/example/test_driver/extended_integration_test.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:flutter_driver/flutter_driver.dart'; -import 'package:integration_test/integration_test_driver_extended.dart'; - -Future main() async { - final FlutterDriver driver = await FlutterDriver.connect(); - await integrationDriver( - driver: driver, - onScreenshot: (String screenshotName, List screenshotBytes) async { - return true; - }, - ); -} diff --git a/packages/integration_test/example/test_driver/failure.dart b/packages/integration_test/example/test_driver/failure.dart deleted file mode 100644 index 02fc55e94..000000000 --- a/packages/integration_test/example/test_driver/failure.dart +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; - -import 'package:integration_test_example/main.dart' as app; - -/// This file is placed in `test_driver/` instead of `integration_test/`, so -/// that the CI tooling of flutter/plugins only uses this together with -/// `failure_test.dart` as the driver. It is only used for testing of -/// `package:integration_test` – do not follow the conventions here if you are a -/// user of `package:integration_test`. - -// Tests the failure behavior of the IntegrationTestWidgetsFlutterBinding -// -// This test fails intentionally! It should be run using a test runner that -// expects failure. -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - testWidgets('success', (WidgetTester tester) async { - expect(1 + 1, 2); // This should pass - }); - - testWidgets('failure 1', (WidgetTester tester) async { - // Build our app and trigger a frame. - app.main(); - - // Verify that platform version is retrieved. - await expectLater( - find.byWidgetPredicate( - (Widget widget) => - widget is Text && widget.data.startsWith('This should fail'), - ), - findsOneWidget, - ); - }); - - testWidgets('failure 2', (WidgetTester tester) async { - expect(1 + 1, 3); // This should fail - }); -} diff --git a/packages/integration_test/example/test_driver/failure_test.dart b/packages/integration_test/example/test_driver/failure_test.dart deleted file mode 100644 index fce6adc42..000000000 --- a/packages/integration_test/example/test_driver/failure_test.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:flutter_driver/flutter_driver.dart'; -import 'package:integration_test/common.dart' as common; -import 'package:test/test.dart'; - -/// This file is only used for testing of `package:integration_test` – do not -/// follow the conventions here if you are a user of `package:integration_test`. - -Future main() async { - test('fails gracefully', () async { - final FlutterDriver driver = await FlutterDriver.connect(); - final String jsonResult = - await driver.requestData(null, timeout: const Duration(minutes: 1)); - common.Response response = common.Response.fromJson(jsonResult); - await driver.close(); - expect( - response.allTestsPassed, - false, - ); - }); -} diff --git a/packages/integration_test/example/test_driver/integration_test.dart b/packages/integration_test/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/integration_test/example/test_driver/integration_test.dart +++ b/packages/integration_test/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/integration_test/pubspec.yaml b/packages/integration_test/pubspec.yaml index 5cdd6d55f..edcab2355 100644 --- a/packages/integration_test/pubspec.yaml +++ b/packages/integration_test/pubspec.yaml @@ -1,6 +1,6 @@ name: integration_test_tizen description: Tizen implementation of the integration_test plugin -version: 1.0.1 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -13,14 +13,7 @@ flutter: dependencies: flutter: sdk: flutter - flutter_driver: - sdk: flutter - flutter_test: - sdk: flutter - -dev_dependencies: - integration_test: ^1.0.1 environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/package_info/CHANGELOG.md b/packages/package_info/CHANGELOG.md index 32f490b5f..354c6542b 100644 --- a/packages/package_info/CHANGELOG.md +++ b/packages/package_info/CHANGELOG.md @@ -1,3 +1,10 @@ ## 1.0.0 * Initial release + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Organize dev_dependencies diff --git a/packages/package_info/LICENSE b/packages/package_info/LICENSE index 934dd180c..29b9b9d1e 100644 --- a/packages/package_info/LICENSE +++ b/packages/package_info/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2017 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/package_info/README.md b/packages/package_info/README.md index 88a77b985..43a8be008 100644 --- a/packages/package_info/README.md +++ b/packages/package_info/README.md @@ -8,8 +8,8 @@ This package is not an _endorsed_ implementation of `package_info`. Therefore, y ```yaml dependencies: - package_info: ^0.4.3 - package_info_tizen: ^1.0.0 + package_info: ^2.0.0 + package_info_tizen: ^2.0.0 ``` Then you can import `package_info` in your Dart code: @@ -42,4 +42,4 @@ For detailed usage, see https://github.com/flutter/plugins/blob/master/packages/ This plugin is supported on these types of devices: -- Galaxy Watch (running Tizen 4.0 or later) \ No newline at end of file +- Galaxy Watch (running Tizen 4.0 or later) diff --git a/packages/package_info/example/integration_test/package_info_test.dart b/packages/package_info/example/integration_test/package_info_test.dart index aac2570e5..e12bc0d0d 100644 --- a/packages/package_info/example/integration_test/package_info_test.dart +++ b/packages/package_info/example/integration_test/package_info_test.dart @@ -1,8 +1,9 @@ -// Copyright 2019, the Chromium project authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io'; +// @dart=2.9 + import 'package:flutter_test/flutter_test.dart'; import 'package:integration_test/integration_test.dart'; import 'package:package_info/package_info.dart'; diff --git a/packages/package_info/example/lib/main.dart b/packages/package_info/example/lib/main.dart index da54b23bc..a679e08a3 100644 --- a/packages/package_info/example/lib/main.dart +++ b/packages/package_info/example/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,13 +19,13 @@ class MyApp extends StatelessWidget { return MaterialApp( title: 'PackageInfo Demo', theme: ThemeData(primarySwatch: Colors.blue), - home: MyHomePage(title: 'PackageInfo example app'), + home: const MyHomePage(title: 'PackageInfo example app'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @@ -38,6 +38,7 @@ class _MyHomePageState extends State { appName: 'Unknown', packageName: 'Unknown', version: 'Unknown', + buildNumber: 'Unknown', ); @override @@ -56,7 +57,7 @@ class _MyHomePageState extends State { Widget _infoTile(String title, String subtitle) { return ListTile( title: Text(title), - subtitle: Text(subtitle ?? 'Not set'), + subtitle: Text(subtitle.isNotEmpty ? subtitle : 'Not set'), ); } diff --git a/packages/package_info/example/pubspec.yaml b/packages/package_info/example/pubspec.yaml index 7bd63f5bc..03eecc780 100644 --- a/packages/package_info/example/pubspec.yaml +++ b/packages/package_info/example/pubspec.yaml @@ -1,19 +1,21 @@ name: package_info_example -description: Demonstrates how to use the package_info plugin. +description: Demonstrates how to use the package_info_tizen plugin. publish_to: 'none' dependencies: flutter: sdk: flutter - package_info: ^0.4.3 + package_info: ^2.0.0 package_info_tizen: path: ../ dev_dependencies: flutter_driver: sdk: flutter - test: any - integration_test: ^1.0.1 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter integration_test_tizen: path: ../../integration_test/ @@ -21,5 +23,5 @@ flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/package_info/example/test_driver/integration_test.dart b/packages/package_info/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/package_info/example/test_driver/integration_test.dart +++ b/packages/package_info/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/package_info/pubspec.yaml b/packages/package_info/pubspec.yaml index f4dde68dd..bbb007ce6 100644 --- a/packages/package_info/pubspec.yaml +++ b/packages/package_info/pubspec.yaml @@ -1,7 +1,7 @@ name: package_info_tizen description: Flutter plugin for querying information about the application package on Tizen platofrm. -version: 1.0.0 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -15,12 +15,6 @@ dependencies: flutter: sdk: flutter -dev_dependencies: - flutter_test: - sdk: flutter - flutter_driver: - sdk: flutter - environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/path_provider/CHANGELOG.md b/packages/path_provider/CHANGELOG.md index 94a53b682..319ccd130 100644 --- a/packages/path_provider/CHANGELOG.md +++ b/packages/path_provider/CHANGELOG.md @@ -4,8 +4,8 @@ ## 1.0.1 -* Update path_provider to the latest (1.6.27) -* Update platform interface to the latest (1.0.4) +* Update path_provider to 1.6.27 +* Update platform interface to 1.0.4 * Remove permission_handler_tizen dependency temporarily * Migrate to Tizen 4.0 @@ -13,3 +13,14 @@ * Use `PlatformException` instead of a plugin-specific exception type (`StorageException`) + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Update platform interface to 2.0.1 +* Update permission_handler to 6.1.1 +* Organize dev_dependencies +* Migrate to ffi 1.0.0 +* Migrate to null safety diff --git a/packages/path_provider/LICENSE b/packages/path_provider/LICENSE index 7f6595961..5eee0ec43 100644 --- a/packages/path_provider/LICENSE +++ b/packages/path_provider/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2019 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/path_provider/README.md b/packages/path_provider/README.md index 400c36a41..c96b99b44 100644 --- a/packages/path_provider/README.md +++ b/packages/path_provider/README.md @@ -8,8 +8,8 @@ This package is not an _endorsed_ implementation of `path_provider`. Therefore, ```yaml dependencies: - path_provider: ^1.6.27 - path_provider_tizen: ^1.0.2 + path_provider: ^2.0.1 + path_provider_tizen: ^2.0.0 ``` Then you can import `path_provider` in your Dart code: diff --git a/packages/path_provider/example/integration_test/path_provider_test.dart b/packages/path_provider/example/integration_test/path_provider_test.dart index 5268478ff..228c3405d 100644 --- a/packages/path_provider/example/integration_test/path_provider_test.dart +++ b/packages/path_provider/example/integration_test/path_provider_test.dart @@ -1,14 +1,16 @@ -// Copyright 2019 the Chromium project authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// @dart=2.9 + import 'dart:async'; import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:integration_test/integration_test.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:integration_test/integration_test.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); @@ -54,7 +56,7 @@ void main() { expect(result, throwsA(isInstanceOf())); } else if (Platform.isAndroid) { final List directories = await getExternalCacheDirectories(); - for (Directory result in directories) { + for (final Directory result in directories) { _verifySampleFile(result, 'externalCache'); } } @@ -70,7 +72,7 @@ void main() { StorageDirectory.movies, ]; - for (StorageDirectory type in _allDirs) { + for (final StorageDirectory type in _allDirs) { test('getExternalStorageDirectories (type: $type)', () async { if (Platform.isIOS) { final Future> result = @@ -83,7 +85,7 @@ void main() { } final List directories = await getExternalStorageDirectories(type: type); - for (Directory result in directories) { + for (final Directory result in directories) { _verifySampleFile(result, '$type'); } } diff --git a/packages/path_provider/example/lib/main.dart b/packages/path_provider/example/lib/main.dart index a100ee110..13728bbfd 100644 --- a/packages/path_provider/example/lib/main.dart +++ b/packages/path_provider/example/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright 2019 The Flutter Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -22,13 +22,13 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(title: 'Path Provider'), + home: const MyHomePage(title: 'Path Provider'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @override @@ -36,14 +36,13 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - Future _tempDirectory; - Future _appSupportDirectory; - Future _appLibraryDirectory; - Future _appDocumentsDirectory; - Future _appDownloadsDirectory; - Future _externalDocumentsDirectory; - Future> _externalStorageDirectories; - Future> _externalCacheDirectories; + Future? _tempDirectory; + Future? _appSupportDirectory; + Future? _appLibraryDirectory; + Future? _appDocumentsDirectory; + Future? _externalDocumentsDirectory; + Future?>? _externalStorageDirectories; + Future?>? _externalCacheDirectories; void _requestTempDirectory() { setState(() { @@ -52,13 +51,13 @@ class _MyHomePageState extends State { } Widget _buildDirectory( - BuildContext context, AsyncSnapshot snapshot) { + BuildContext context, AsyncSnapshot snapshot) { Text text = const Text(''); if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { text = Text('Error: ${snapshot.error}'); } else if (snapshot.hasData) { - text = Text('path: ${snapshot.data.path}'); + text = Text('path: ${snapshot.data!.path}'); } else { text = const Text('path unavailable'); } @@ -67,14 +66,14 @@ class _MyHomePageState extends State { } Widget _buildDirectories( - BuildContext context, AsyncSnapshot> snapshot) { + BuildContext context, AsyncSnapshot?> snapshot) { Text text = const Text(''); if (snapshot.connectionState == ConnectionState.done) { if (snapshot.hasError) { text = Text('Error: ${snapshot.error}'); } else if (snapshot.hasData) { final String combined = - snapshot.data.map((Directory d) => d.path).join(', '); + snapshot.data!.map((Directory d) => d.path).join(', '); text = Text('paths: $combined'); } else { text = const Text('path unavailable'); @@ -89,12 +88,6 @@ class _MyHomePageState extends State { }); } - void _requestAppDownloadsDirectory() { - setState(() { - _appDownloadsDirectory = getDownloadsDirectory(); - }); - } - void _requestAppSupportDirectory() { setState(() { _appSupportDirectory = getApplicationSupportDirectory(); @@ -135,67 +128,60 @@ class _MyHomePageState extends State { child: ListView( children: [ Padding( - padding: const EdgeInsets.all(6.0), - child: RaisedButton( - child: const Text('Get Application Documents Directory'), - onPressed: _requestAppDocumentsDirectory, - ), - ), - FutureBuilder( - future: _appDocumentsDirectory, builder: _buildDirectory), - Padding( - padding: const EdgeInsets.all(6.0), - child: RaisedButton( - child: const Text('Get Application Downloads Directory'), - onPressed: _requestAppDownloadsDirectory, - ), - ), - FutureBuilder( - future: _appDownloadsDirectory, builder: _buildDirectory), - Padding( - padding: const EdgeInsets.all(6.0), - child: RaisedButton( + padding: const EdgeInsets.all(16.0), + child: ElevatedButton( child: const Text('Get Temporary Directory'), onPressed: _requestTempDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _tempDirectory, builder: _buildDirectory), Padding( - padding: const EdgeInsets.all(6.0), - child: RaisedButton( + padding: const EdgeInsets.all(16.0), + child: ElevatedButton( + child: const Text('Get Application Documents Directory'), + onPressed: _requestAppDocumentsDirectory, + ), + ), + FutureBuilder( + future: _appDocumentsDirectory, builder: _buildDirectory), + Padding( + padding: const EdgeInsets.all(16.0), + child: ElevatedButton( child: const Text('Get Application Support Directory'), onPressed: _requestAppSupportDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _appSupportDirectory, builder: _buildDirectory), Padding( - padding: const EdgeInsets.all(6.0), - child: RaisedButton( + padding: const EdgeInsets.all(16.0), + child: ElevatedButton( child: const Text('Get Application Library Directory'), onPressed: _requestAppLibraryDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _appLibraryDirectory, builder: _buildDirectory), Padding( - padding: const EdgeInsets.all(6.0), - child: RaisedButton( - child: Text( - '${Platform.isIOS ? "External directories are unavailable " "on iOS" : "Get External Storage Directory"}'), + padding: const EdgeInsets.all(16.0), + child: ElevatedButton( + child: Text(Platform.isIOS + ? 'External directories are unavailable on iOS' + : 'Get External Storage Directory'), onPressed: Platform.isIOS ? null : _requestExternalStorageDirectory, ), ), - FutureBuilder( + FutureBuilder( future: _externalDocumentsDirectory, builder: _buildDirectory), Column(children: [ Padding( - padding: const EdgeInsets.all(6.0), - child: RaisedButton( - child: Text( - '${Platform.isIOS ? "External directories are unavailable " "on iOS" : "Get External Storage Directories"}'), + padding: const EdgeInsets.all(16.0), + child: ElevatedButton( + child: Text(Platform.isIOS + ? 'External directories are unavailable on iOS' + : 'Get External Storage Directories'), onPressed: Platform.isIOS ? null : () { @@ -206,21 +192,22 @@ class _MyHomePageState extends State { ), ), ]), - FutureBuilder>( + FutureBuilder?>( future: _externalStorageDirectories, builder: _buildDirectories), Column(children: [ Padding( - padding: const EdgeInsets.all(6.0), - child: RaisedButton( - child: Text( - '${Platform.isIOS ? "External directories are unavailable " "on iOS" : "Get External Cache Directories"}'), + padding: const EdgeInsets.all(16.0), + child: ElevatedButton( + child: Text(Platform.isIOS + ? 'External directories are unavailable on iOS' + : 'Get External Cache Directories'), onPressed: Platform.isIOS ? null : _requestExternalCacheDirectories, ), ), ]), - FutureBuilder>( + FutureBuilder?>( future: _externalCacheDirectories, builder: _buildDirectories), ], ), diff --git a/packages/path_provider/example/pubspec.yaml b/packages/path_provider/example/pubspec.yaml index b8a68d7ab..5d5f9373c 100644 --- a/packages/path_provider/example/pubspec.yaml +++ b/packages/path_provider/example/pubspec.yaml @@ -5,21 +5,24 @@ publish_to: 'none' dependencies: flutter: sdk: flutter - path_provider: ^1.6.27 + path_provider: ^2.0.1 path_provider_tizen: path: ../ dev_dependencies: - integration_test: ^1.0.1 - integration_test_tizen: - path: ../../integration_test/ - permission_handler: ^5.0.1+1 flutter_driver: sdk: flutter + flutter_test: + sdk: flutter + integration_test: + sdk: flutter + integration_test_tizen: + path: ../../integration_test/ + permission_handler: ^6.1.1 flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/path_provider/example/test_driver/integration_test.dart b/packages/path_provider/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/path_provider/example/test_driver/integration_test.dart +++ b/packages/path_provider/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/path_provider/lib/path_provider_tizen.dart b/packages/path_provider/lib/path_provider_tizen.dart index 54895835f..a41acc27d 100644 --- a/packages/path_provider/lib/path_provider_tizen.dart +++ b/packages/path_provider/lib/path_provider_tizen.dart @@ -3,55 +3,42 @@ // found in the LICENSE file. import 'dart:async'; + import 'package:path_provider_platform_interface/path_provider_platform_interface.dart'; import 'src/app_common.dart'; import 'src/storage.dart'; -/// The Tizen implementation of [PathProviderPlatform] +/// The Tizen implementation of [PathProviderPlatform]. /// -/// This class implements the `package:path_provider` functionality for Tizen +/// This class implements the `package:path_provider` functionality for Tizen. class PathProviderPlugin extends PathProviderPlatform { - /// Registers this class as the default instance of [PathProviderPlatform] + /// Registers this class as the default instance of [PathProviderPlatform]. static void register() { PathProviderPlatform.instance = PathProviderPlugin(); } @override - Future getTemporaryPath() async { - assert(appCommon != null); - return appCommon.getCachePath(); - } + Future getTemporaryPath() async => appCommon.getCachePath(); @override - Future getApplicationDocumentsPath() async { - assert(appCommon != null); - return appCommon.getDataPath(); - } + Future getApplicationDocumentsPath() async => appCommon.getDataPath(); @override - Future getApplicationSupportPath() async { - assert(appCommon != null); - return appCommon.getDataPath(); - } + Future getApplicationSupportPath() async => appCommon.getDataPath(); @override - Future getExternalStoragePath() async { - assert(appCommon != null); - return appCommon.getExternalDataPath(); - } + Future getExternalStoragePath() async => + appCommon.getExternalDataPath(); @override - Future> getExternalCachePaths() async { - assert(appCommon != null); - return [appCommon.getExternalCachePath()]; - } + Future> getExternalCachePaths() async => + [appCommon.getExternalCachePath()]; @override Future> getExternalStoragePaths({ - StorageDirectory type, + StorageDirectory? type, }) async { - assert(storage != null); StorageDirectoryType dirType; switch (type) { case StorageDirectory.music: @@ -86,8 +73,6 @@ class PathProviderPlugin extends PathProviderPlatform { } @override - Future getDownloadsPath() async { - assert(storage != null); - return await storage.getDirectory(type: StorageDirectoryType.downloads); - } + Future getDownloadsPath() async => + await storage.getDirectory(type: StorageDirectoryType.downloads); } diff --git a/packages/path_provider/lib/src/app_common.dart b/packages/path_provider/lib/src/app_common.dart index 6d14367af..cc2b59d7e 100644 --- a/packages/path_provider/lib/src/app_common.dart +++ b/packages/path_provider/lib/src/app_common.dart @@ -2,69 +2,86 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: public_member_api_docs + import 'dart:ffi'; + import 'package:ffi/ffi.dart'; -typedef app_common_get_data_path = Pointer Function(); -typedef app_common_get_cache_path = Pointer Function(); -typedef app_common_get_external_data_path = Pointer Function(); -typedef app_common_get_external_cache_path = Pointer Function(); +typedef _app_common_get_data_path = Pointer Function(); +typedef _app_common_get_cache_path = Pointer Function(); +typedef _app_common_get_external_data_path = Pointer Function(); +typedef _app_common_get_external_cache_path = Pointer Function(); -AppCommon _appCommonInstance; +AppCommon? _appCommonInstance; AppCommon get appCommon => _appCommonInstance ??= AppCommon(); -/// A wrapper class for Tizen App Common APIs. -/// Not all functions or values are supported. +/// Dart wrapper of Tizen's `app_common`. +/// +/// See: https://docs.tizen.org/application/native/api/wearable/latest/group__CAPI__APP__COMMON__MODULE.html class AppCommon { AppCommon() { final DynamicLibrary libAppCommon = DynamicLibrary.open('libcapi-appfw-app-common.so.0'); _getDataPath = libAppCommon - .lookup>('app_get_data_path') + .lookup>('app_get_data_path') .asFunction(); _getCachePath = libAppCommon - .lookup>('app_get_cache_path') + .lookup>( + 'app_get_cache_path') .asFunction(); _getExternalDataPath = libAppCommon - .lookup>( + .lookup>( 'app_get_external_data_path') .asFunction(); _getExternalCachePath = libAppCommon - .lookup>( + .lookup>( 'app_get_external_cache_path') .asFunction(); } - Pointer Function() _getDataPath; - Pointer Function() _getCachePath; - Pointer Function() _getExternalDataPath; - Pointer Function() _getExternalCachePath; + late Pointer Function() _getDataPath; + late Pointer Function() _getCachePath; + late Pointer Function() _getExternalDataPath; + late Pointer Function() _getExternalCachePath; + /// Corresponds to `app_get_cache_path()`. String getCachePath() { final Pointer path = _getCachePath(); - final String str = (path != null) ? Utf8.fromUtf8(path) : ''; - free(path); + final String str = path.toDartString(); + if (path != nullptr) { + malloc.free(path); + } return str; } + /// Corresponds to `app_get_data_path()`. String getDataPath() { final Pointer path = _getDataPath(); - final String str = (path != null) ? Utf8.fromUtf8(path) : ''; - free(path); + final String str = path.toDartString(); + if (path != nullptr) { + malloc.free(path); + } return str; } + /// Corresponds to `app_get_external_data_path()`. String getExternalDataPath() { final Pointer path = _getExternalDataPath(); - final String str = (path != null) ? Utf8.fromUtf8(path) : ''; - free(path); + final String str = path.toDartString(); + if (path != nullptr) { + malloc.free(path); + } return str; } + /// Corresponds to `app_get_external_cache_path()`. String getExternalCachePath() { final Pointer path = _getExternalCachePath(); - final String str = (path != null) ? Utf8.fromUtf8(path) : ''; - free(path); + final String str = path.toDartString(); + if (path != nullptr) { + malloc.free(path); + } return str; } } diff --git a/packages/path_provider/lib/src/storage.dart b/packages/path_provider/lib/src/storage.dart index fe51fb5eb..988d839eb 100644 --- a/packages/path_provider/lib/src/storage.dart +++ b/packages/path_provider/lib/src/storage.dart @@ -2,19 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: public_member_api_docs + import 'dart:async'; import 'dart:ffi'; + import 'package:ffi/ffi.dart'; import 'package:flutter/services.dart'; -// Native function signatures -typedef storage_get_directory = Int32 Function( +typedef _storage_get_directory = Int32 Function( Int32, Int32, Pointer>); typedef _storage_callback = Int32 Function( Int32, Int32, Int32, Pointer, Pointer); -typedef storage_foreach_device_supported = Int32 Function( +typedef _storage_foreach_device_supported = Int32 Function( Pointer>, Pointer); +/// Corresponds to `storage_directory_e`. enum StorageDirectoryType { images, sounds, @@ -27,20 +30,21 @@ enum StorageDirectoryType { system_ringtones, } -Storage _storageInstance; +Storage? _storageInstance; Storage get storage => _storageInstance ??= Storage(); -/// A wrapper class for Tizen Storage APIs. -/// Not all functions or values are supported. +/// Dart wrapper of Tizen's `storage`. +/// +/// See: https://docs.tizen.org/application/native/api/wearable/latest/group__CAPI__SYSTEM__STORAGE__MODULE.html class Storage { Storage() { final DynamicLibrary libStorage = DynamicLibrary.open('libstorage.so.0.1'); _storageGetDirectory = libStorage - .lookup>('storage_get_directory') + .lookup>('storage_get_directory') .asFunction(); _storageForeachDeviceSupported = libStorage - .lookup>( + .lookup>( 'storage_foreach_device_supported') .asFunction(); @@ -58,9 +62,8 @@ class Storage { } } - // Bindings - int Function(int, int, Pointer>) _storageGetDirectory; - int Function(Pointer>, Pointer) + late int Function(int, int, Pointer>) _storageGetDirectory; + late int Function(Pointer>, Pointer) _storageForeachDeviceSupported; /// The unique storage device id. @@ -84,10 +87,11 @@ class Storage { return 1; } + /// Corresponds to `storage_get_directory()`. Future getDirectory({ - StorageDirectoryType type, + required StorageDirectoryType type, }) async { - final Pointer> path = allocate(); + final Pointer> path = malloc(); try { final int ret = _storageGetDirectory(await storageId, type.index, path); if (ret != 0) { @@ -96,9 +100,9 @@ class Storage { message: 'Failed to execute storage_get_directory.', ); } - return Utf8.fromUtf8(path.value); + return path.value.toDartString(); } finally { - free(path); + malloc.free(path); } } } diff --git a/packages/path_provider/pubspec.yaml b/packages/path_provider/pubspec.yaml index 17e067703..82ae8f184 100644 --- a/packages/path_provider/pubspec.yaml +++ b/packages/path_provider/pubspec.yaml @@ -1,6 +1,6 @@ name: path_provider_tizen description: Tizen implementation of the path_provider plugin -version: 1.0.2 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -11,15 +11,11 @@ flutter: fileName: path_provider_tizen.dart dependencies: + ffi: ^1.0.0 flutter: sdk: flutter - path_provider_platform_interface: ^1.0.4 - ffi: ^0.1.3 - -dev_dependencies: - flutter_test: - sdk: flutter + path_provider_platform_interface: ^2.0.1 environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: '>=2.12.0 <3.0.0' + flutter: ">=2.0.0" diff --git a/packages/sensors/CHANGELOG.md b/packages/sensors/CHANGELOG.md index d9e97a6a5..1f990074b 100644 --- a/packages/sensors/CHANGELOG.md +++ b/packages/sensors/CHANGELOG.md @@ -4,5 +4,12 @@ ## 1.0.1 -* Update sensors to the latest (0.4.2+6) +* Update sensors to 0.4.2+6 * Migrate to Tizen 4.0 + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Organize dev_dependencies diff --git a/packages/sensors/LICENSE b/packages/sensors/LICENSE index 4e5cfe14e..5eee0ec43 100644 --- a/packages/sensors/LICENSE +++ b/packages/sensors/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2017 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/sensors/README.md b/packages/sensors/README.md index 8037ece32..de9ba57ef 100644 --- a/packages/sensors/README.md +++ b/packages/sensors/README.md @@ -8,8 +8,8 @@ This package is not an _endorsed_ implementation of `sensors`. Therefore, you ha ```yaml dependencies: - sensors: ^0.4.2+6 - sensors_tizen: ^1.0.1 + sensors: ^2.0.0 + sensors_tizen: ^2.0.0 ``` Then you can import `sensors` in your Dart code: diff --git a/packages/sensors/example/README.md b/packages/sensors/example/README.md index b58d0ec33..48117992a 100644 --- a/packages/sensors/example/README.md +++ b/packages/sensors/example/README.md @@ -1,6 +1,6 @@ # sensors_example -Demonstrates how to use the sensors plugin. +Demonstrates how to use the sensors_tizen plugin. ## Getting Started diff --git a/packages/sensors/integration_test/sensors_test.dart b/packages/sensors/example/integration_test/sensors_test.dart similarity index 91% rename from packages/sensors/integration_test/sensors_test.dart rename to packages/sensors/example/integration_test/sensors_test.dart index f38107175..3b8f614d2 100644 --- a/packages/sensors/integration_test/sensors_test.dart +++ b/packages/sensors/example/integration_test/sensors_test.dart @@ -1,7 +1,9 @@ -// Copyright 2019 the Chromium project authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// @dart = 2.9 + import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; import 'package:sensors/sensors.dart'; diff --git a/packages/sensors/example/lib/main.dart b/packages/sensors/example/lib/main.dart index 575e04937..180565df4 100644 --- a/packages/sensors/example/lib/main.dart +++ b/packages/sensors/example/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -22,13 +22,13 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(title: 'Flutter Demo Home Page'), + home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @@ -41,21 +41,21 @@ class _MyHomePageState extends State { static const int _snakeColumns = 20; static const double _snakeCellSize = 10.0; - List _accelerometerValues; - List _userAccelerometerValues; - List _gyroscopeValues; - List> _streamSubscriptions = + List? _accelerometerValues; + List? _userAccelerometerValues; + List? _gyroscopeValues; + final List> _streamSubscriptions = >[]; @override Widget build(BuildContext context) { - final List accelerometer = - _accelerometerValues?.map((double v) => v.toStringAsFixed(1))?.toList(); - final List gyroscope = - _gyroscopeValues?.map((double v) => v.toStringAsFixed(1))?.toList(); - final List userAccelerometer = _userAccelerometerValues + final List? accelerometer = + _accelerometerValues?.map((double v) => v.toStringAsFixed(1)).toList(); + final List? gyroscope = + _gyroscopeValues?.map((double v) => v.toStringAsFixed(1)).toList(); + final List? userAccelerometer = _userAccelerometerValues ?.map((double v) => v.toStringAsFixed(1)) - ?.toList(); + .toList(); return Scaffold( appBar: AppBar( @@ -69,7 +69,7 @@ class _MyHomePageState extends State { decoration: BoxDecoration( border: Border.all(width: 1.0, color: Colors.black38), ), - child: SizedBox( + child: const SizedBox( height: _snakeRows * _snakeCellSize, width: _snakeColumns * _snakeCellSize, child: Snake( @@ -115,7 +115,8 @@ class _MyHomePageState extends State { @override void dispose() { super.dispose(); - for (StreamSubscription subscription in _streamSubscriptions) { + for (final StreamSubscription subscription + in _streamSubscriptions) { subscription.cancel(); } } diff --git a/packages/sensors/example/lib/snake.dart b/packages/sensors/example/lib/snake.dart index d6b2f9b48..371308880 100644 --- a/packages/sensors/example/lib/snake.dart +++ b/packages/sensors/example/lib/snake.dart @@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,17 +11,17 @@ import 'package:flutter/material.dart'; import 'package:sensors/sensors.dart'; class Snake extends StatefulWidget { - Snake({this.rows = 20, this.columns = 20, this.cellSize = 10.0}) { - assert(10 <= rows); - assert(10 <= columns); - assert(5.0 <= cellSize); - } + const Snake({this.rows = 20, this.columns = 20, this.cellSize = 10.0}) + : assert(10 <= rows), + assert(10 <= columns), + assert(5.0 <= cellSize); final int rows; final int columns; final double cellSize; @override + // ignore: no_logic_in_create_state State createState() => SnakeState(rows, columns, cellSize); } @@ -41,7 +41,7 @@ class SnakeBoardPainter extends CustomPainter { Rect.fromPoints(Offset.zero, size.bottomLeft(Offset.zero)), blackLine, ); - for (math.Point p in state.body) { + for (final math.Point p in state.body) { final Offset a = Offset(cellSize * p.x, cellSize * p.y); final Offset b = Offset(cellSize * (p.x + 1), cellSize * (p.y + 1)); @@ -56,15 +56,14 @@ class SnakeBoardPainter extends CustomPainter { } class SnakeState extends State { - SnakeState(int rows, int columns, this.cellSize) { - state = GameState(rows, columns); - } + SnakeState(int rows, int columns, this.cellSize) + : state = GameState(rows, columns); double cellSize; GameState state; - AccelerometerEvent acceleration; - StreamSubscription _streamSubscription; - Timer _timer; + AccelerometerEvent? acceleration; + late StreamSubscription _streamSubscription; + late Timer _timer; @override Widget build(BuildContext context) { @@ -96,21 +95,21 @@ class SnakeState extends State { } void _step() { - final math.Point newDirection = acceleration == null + final AccelerometerEvent? currentAcceleration = acceleration; + final math.Point? newDirection = currentAcceleration == null ? null - : acceleration.x.abs() < 1.0 && acceleration.y.abs() < 1.0 + : currentAcceleration.x.abs() < 1.0 && currentAcceleration.y.abs() < 1.0 ? null - : (acceleration.x.abs() < acceleration.y.abs()) - ? math.Point(0, acceleration.y.sign.toInt()) - : math.Point(-acceleration.x.sign.toInt(), 0); + : (currentAcceleration.x.abs() < currentAcceleration.y.abs()) + ? math.Point(0, currentAcceleration.y.sign.toInt()) + : math.Point(-currentAcceleration.x.sign.toInt(), 0); state.step(newDirection); } } class GameState { - GameState(this.rows, this.columns) { - snakeLength = math.min(rows, columns) - 5; - } + GameState(this.rows, this.columns) + : snakeLength = math.min(rows, columns) - 5; int rows; int columns; @@ -119,12 +118,14 @@ class GameState { List> body = >[const math.Point(0, 0)]; math.Point direction = const math.Point(1, 0); - void step(math.Point newDirection) { + void step(math.Point? newDirection) { math.Point next = body.last + direction; next = math.Point(next.x % columns, next.y % rows); body.add(next); - if (body.length > snakeLength) body.removeAt(0); + if (body.length > snakeLength) { + body.removeAt(0); + } direction = newDirection ?? direction; } } diff --git a/packages/sensors/example/pubspec.yaml b/packages/sensors/example/pubspec.yaml index 0db5b9634..12d066f5a 100644 --- a/packages/sensors/example/pubspec.yaml +++ b/packages/sensors/example/pubspec.yaml @@ -5,14 +5,17 @@ publish_to: 'none' dependencies: flutter: sdk: flutter - sensors: ^0.4.2+6 + sensors: ^2.0.0 sensors_tizen: path: ../ dev_dependencies: flutter_driver: sdk: flutter - integration_test: ^1.0.1 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter integration_test_tizen: path: ../../integration_test/ @@ -20,5 +23,5 @@ flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/sensors/example/test_driver/integration_test.dart b/packages/sensors/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/sensors/example/test_driver/integration_test.dart +++ b/packages/sensors/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/sensors/pubspec.yaml b/packages/sensors/pubspec.yaml index 93243a163..969656bfb 100644 --- a/packages/sensors/pubspec.yaml +++ b/packages/sensors/pubspec.yaml @@ -1,7 +1,7 @@ name: sensors_tizen description: Tizen implementation of the sensors plugin homepage: https://github.com/flutter-tizen/plugins -version: 1.0.1 +version: 2.0.0 flutter: plugin: @@ -14,15 +14,6 @@ dependencies: flutter: sdk: flutter -dev_dependencies: - test: ^1.3.0 - flutter_test: - sdk: flutter - integration_test: ^1.0.1 - integration_test_tizen: - path: ../integration_test - sensors: ^0.4.2+6 - environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/share/CHANGELOG.md b/packages/share/CHANGELOG.md index 32f490b5f..6e070f2fd 100644 --- a/packages/share/CHANGELOG.md +++ b/packages/share/CHANGELOG.md @@ -1,3 +1,12 @@ ## 1.0.0 * Initial release + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Update image_picker to 0.7.3 +* Organize dev_dependencies +* Replace pointer-based `Success()` with reference-based version diff --git a/packages/share/LICENSE b/packages/share/LICENSE index e608d6e8d..29b9b9d1e 100644 --- a/packages/share/LICENSE +++ b/packages/share/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2019 The Flutter Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/share/README.md b/packages/share/README.md index b15758c6d..359481be6 100644 --- a/packages/share/README.md +++ b/packages/share/README.md @@ -6,6 +6,12 @@ The Tizen implementation of [`share`](https://github.com/flutter/plugins/tree/ma To use this plugin, add `share` and `share_tizen` as [dependencies in your pubspec.yaml file](https://flutter.io/platform-plugins/). +```yaml +dependencies: + share: ^2.0.1 + share_tizen: ^2.0.0 +``` + ## Example Import the library. @@ -28,7 +34,7 @@ Share.share('check out my website https://example.com'); ## Required privileges -To use this plugin, you need to declare privileges in tizen-manifest.xml of your application. +To use this plugin, you need to declare privileges in `tizen-manifest.xml` of your application. ``` xml diff --git a/packages/share/example/README.md b/packages/share/example/README.md index d3ae8eb63..694c7e205 100644 --- a/packages/share/example/README.md +++ b/packages/share/example/README.md @@ -1,3 +1,3 @@ # share_example -Demonstrates how to use the share plugin. +Demonstrates how to use the share_tizen plugin. diff --git a/packages/share/example/integration_test/share_test.dart b/packages/share/example/integration_test/share_test.dart index 2b025049f..ae9dfea4f 100644 --- a/packages/share/example/integration_test/share_test.dart +++ b/packages/share/example/integration_test/share_test.dart @@ -1,6 +1,6 @@ -// Copyright 2019, the Chromium project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. // @dart = 2.9 diff --git a/packages/share/example/lib/image_previews.dart b/packages/share/example/lib/image_previews.dart index 61ecec43b..9b5b807c7 100644 --- a/packages/share/example/lib/image_previews.dart +++ b/packages/share/example/lib/image_previews.dart @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + import 'dart:io'; import 'package:flutter/material.dart'; @@ -9,11 +13,11 @@ class ImagePreviews extends StatelessWidget { final List imagePaths; /// Callback when an image should be removed - final Function(int) onDelete; + final Function(int)? onDelete; /// Creates a widget for preview of images. [imagePaths] can not be empty /// and all contained paths need to be non empty. - const ImagePreviews(this.imagePaths, {Key key, this.onDelete}) + const ImagePreviews(this.imagePaths, {Key? key, this.onDelete}) : super(key: key); @override @@ -26,7 +30,7 @@ class ImagePreviews extends StatelessWidget { for (int i = 0; i < imagePaths.length; i++) { imageWidgets.add(_ImagePreview( imagePaths[i], - onDelete: onDelete != null ? () => onDelete(i) : null, + onDelete: onDelete != null ? () => onDelete!(i) : null, )); } @@ -39,9 +43,9 @@ class ImagePreviews extends StatelessWidget { class _ImagePreview extends StatelessWidget { final String imagePath; - final VoidCallback onDelete; + final VoidCallback? onDelete; - const _ImagePreview(this.imagePath, {Key key, this.onDelete}) + const _ImagePreview(this.imagePath, {Key? key, this.onDelete}) : super(key: key); @override diff --git a/packages/share/example/lib/main.dart b/packages/share/example/lib/main.dart index d6f1a1622..cb1257dcd 100644 --- a/packages/share/example/lib/main.dart +++ b/packages/share/example/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright 2019 The Flutter Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -78,7 +78,7 @@ class DemoAppState extends State { const Padding(padding: EdgeInsets.only(top: 12.0)), Builder( builder: (BuildContext context) { - return RaisedButton( + return ElevatedButton( child: const Text('Share'), onPressed: text.isEmpty && imagePaths.isEmpty ? null @@ -86,6 +86,15 @@ class DemoAppState extends State { ); }, ), + const Padding(padding: EdgeInsets.only(top: 12.0)), + Builder( + builder: (BuildContext context) { + return ElevatedButton( + child: const Text('Share With Empty Origin'), + onPressed: () => _onShareWithEmptyOrigin(context), + ); + }, + ), ], ), ), @@ -93,21 +102,21 @@ class DemoAppState extends State { ); } - _onDeleteImage(int position) { + dynamic _onDeleteImage(int position) { setState(() { imagePaths.removeAt(position); }); } - _onShare(BuildContext context) async { + dynamic _onShare(BuildContext context) async { // A builder is used to retrieve the context immediately - // surrounding the RaisedButton. + // surrounding the ElevatedButton. // // The context's `findRenderObject` returns the first // RenderObject in its descendent tree when it's not - // a RenderObjectWidget. The RaisedButton's RenderObject + // a RenderObjectWidget. The ElevatedButton's RenderObject // has its position and size after it's built. - final RenderBox box = context.findRenderObject(); + final RenderBox box = context.findRenderObject() as RenderBox; if (imagePaths.isNotEmpty) { await Share.shareFiles(imagePaths, @@ -120,4 +129,8 @@ class DemoAppState extends State { sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size); } } + + dynamic _onShareWithEmptyOrigin(BuildContext context) async { + await Share.share("text"); + } } diff --git a/packages/share/example/pubspec.yaml b/packages/share/example/pubspec.yaml index 68e434bf6..ac88279dd 100644 --- a/packages/share/example/pubspec.yaml +++ b/packages/share/example/pubspec.yaml @@ -1,21 +1,24 @@ name: share_example -description: Demonstrates how to use the share plugin. +description: Demonstrates how to use the share_tizen plugin. publish_to: 'none' dependencies: flutter: sdk: flutter - share: ^0.6.5+3 - share_tizen: - path: ../ - image_picker: ^0.6.7 + image_picker: ^0.7.3 image_picker_tizen: path: ../../image_picker/ + share: ^2.0.1 + share_tizen: + path: ../ dev_dependencies: flutter_driver: sdk: flutter - integration_test: ^1.0.1 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter integration_test_tizen: path: ../../integration_test/ @@ -23,5 +26,5 @@ flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/share/example/test_driver/integration_test.dart b/packages/share/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/share/example/test_driver/integration_test.dart +++ b/packages/share/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/share/pubspec.yaml b/packages/share/pubspec.yaml index e6cdb9084..5bf370c7b 100644 --- a/packages/share/pubspec.yaml +++ b/packages/share/pubspec.yaml @@ -1,6 +1,6 @@ name: share_tizen description: Flutter plugin for sharing content via the platform share UI on Tizen. -version: 1.0.0 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -13,12 +13,7 @@ flutter: dependencies: flutter: sdk: flutter - mime: ^0.9.7 - -dev_dependencies: - flutter_test: - sdk: flutter environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/share/tizen/src/share_tizen_plugin.cc b/packages/share/tizen/src/share_tizen_plugin.cc index 7040a6862..a05e2b5f4 100644 --- a/packages/share/tizen/src/share_tizen_plugin.cc +++ b/packages/share/tizen/src/share_tizen_plugin.cc @@ -192,7 +192,7 @@ class ShareTizenPlugin : public flutter::Plugin { app_control_destroy(handle); } - result->Success(nullptr); + result->Success(); } std::string ReduceMimeTypes(flutter::EncodableList mimeTypes) { diff --git a/packages/shared_preferences/CHANGELOG.md b/packages/shared_preferences/CHANGELOG.md index f4a5ba9a9..b5d72a30d 100644 --- a/packages/shared_preferences/CHANGELOG.md +++ b/packages/shared_preferences/CHANGELOG.md @@ -4,6 +4,17 @@ ## 1.0.1 -* Update shared_preferences to the latest (0.5.12+4) -* Update platform interface to the latest (1.0.4) +* Update shared_preferences to 0.5.12+4 +* Update platform interface to 1.0.4 * Migrate to Tizen 4.0 + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Update platform interface to 2.0.0 +* Organize dev_dependencies +* Migrate to ffi 1.0.0 +* Migrate to null safety +* Remove unused `PreferenceIsExisiting` from the implementation diff --git a/packages/shared_preferences/LICENSE b/packages/shared_preferences/LICENSE index 4e5cfe14e..5eee0ec43 100644 --- a/packages/shared_preferences/LICENSE +++ b/packages/shared_preferences/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2017 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/shared_preferences/README.md b/packages/shared_preferences/README.md index 51fb169d1..23b7b67a1 100644 --- a/packages/shared_preferences/README.md +++ b/packages/shared_preferences/README.md @@ -8,8 +8,8 @@ This package is not an _endorsed_ implementation of `shared_preferences`. Theref ```yaml dependencies: - shared_preferences: ^0.5.12+4 - shared_preferences_tizen: ^1.0.1 + shared_preferences: ^2.0.5 + shared_preferences_tizen: ^2.0.0 ``` Then you can import `shared_preferences` in your Dart code: diff --git a/packages/shared_preferences/example/integration_test/shared_preferences_test.dart b/packages/shared_preferences/example/integration_test/shared_preferences_test.dart index ad1d2f8b9..11188bcc2 100644 --- a/packages/shared_preferences/example/integration_test/shared_preferences_test.dart +++ b/packages/shared_preferences/example/integration_test/shared_preferences_test.dart @@ -1,7 +1,9 @@ -// Copyright 2019, the Chromium project authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// @dart=2.9 + import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -37,7 +39,7 @@ void main() { preferences.clear(); }); - test('reading', () async { + testWidgets('reading', (WidgetTester _) async { expect(preferences.get('String'), isNull); expect(preferences.get('bool'), isNull); expect(preferences.get('int'), isNull); @@ -50,13 +52,16 @@ void main() { expect(preferences.getStringList('List'), isNull); }); - test('writing', () async { + testWidgets('writing', (WidgetTester _) async { await Future.wait(>[ - preferences.setString('String', kTestValues2['flutter.String']), - preferences.setBool('bool', kTestValues2['flutter.bool']), - preferences.setInt('int', kTestValues2['flutter.int']), - preferences.setDouble('double', kTestValues2['flutter.double']), - preferences.setStringList('List', kTestValues2['flutter.List']) + preferences.setString( + 'String', kTestValues2['flutter.String'] as String), + preferences.setBool('bool', kTestValues2['flutter.bool'] as bool), + preferences.setInt('int', kTestValues2['flutter.int'] as int), + preferences.setDouble( + 'double', kTestValues2['flutter.double'] as double), + preferences.setStringList( + 'List', kTestValues2['flutter.List'] as List) ]); expect(preferences.getString('String'), kTestValues2['flutter.String']); expect(preferences.getBool('bool'), kTestValues2['flutter.bool']); @@ -65,23 +70,27 @@ void main() { expect(preferences.getStringList('List'), kTestValues2['flutter.List']); }); - test('removing', () async { + testWidgets('removing', (WidgetTester _) async { const String key = 'testKey'; - await preferences.setString(key, kTestValues['flutter.String']); - await preferences.setBool(key, kTestValues['flutter.bool']); - await preferences.setInt(key, kTestValues['flutter.int']); - await preferences.setDouble(key, kTestValues['flutter.double']); - await preferences.setStringList(key, kTestValues['flutter.List']); + await preferences.setString(key, kTestValues['flutter.String'] as String); + await preferences.setBool(key, kTestValues['flutter.bool'] as bool); + await preferences.setInt(key, kTestValues['flutter.int'] as int); + await preferences.setDouble(key, kTestValues['flutter.double'] as double); + await preferences.setStringList( + key, kTestValues['flutter.List'] as List); await preferences.remove(key); expect(preferences.get('testKey'), isNull); }); - test('clearing', () async { - await preferences.setString('String', kTestValues['flutter.String']); - await preferences.setBool('bool', kTestValues['flutter.bool']); - await preferences.setInt('int', kTestValues['flutter.int']); - await preferences.setDouble('double', kTestValues['flutter.double']); - await preferences.setStringList('List', kTestValues['flutter.List']); + testWidgets('clearing', (WidgetTester _) async { + await preferences.setString( + 'String', kTestValues['flutter.String'] as String); + await preferences.setBool('bool', kTestValues['flutter.bool'] as bool); + await preferences.setInt('int', kTestValues['flutter.int'] as int); + await preferences.setDouble( + 'double', kTestValues['flutter.double'] as double); + await preferences.setStringList( + 'List', kTestValues['flutter.List'] as List); await preferences.clear(); expect(preferences.getString('String'), null); expect(preferences.getBool('bool'), null); @@ -89,5 +98,18 @@ void main() { expect(preferences.getDouble('double'), null); expect(preferences.getStringList('List'), null); }); + + testWidgets('simultaneous writes', (WidgetTester _) async { + final List> writes = >[]; + final int writeCount = 100; + for (int i = 1; i <= writeCount; i++) { + writes.add(preferences.setInt('int', i)); + } + List result = await Future.wait(writes, eagerError: true); + // All writes should succeed. + expect(result.where((element) => !element), isEmpty); + // The last write should win. + expect(preferences.getInt('int'), writeCount); + }); }); } diff --git a/packages/shared_preferences/example/lib/main.dart b/packages/shared_preferences/example/lib/main.dart index 46daeff67..103481a2d 100644 --- a/packages/shared_preferences/example/lib/main.dart +++ b/packages/shared_preferences/example/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,7 +24,7 @@ class MyApp extends StatelessWidget { } class SharedPreferencesDemo extends StatefulWidget { - SharedPreferencesDemo({Key key}) : super(key: key); + SharedPreferencesDemo({Key? key}) : super(key: key); @override SharedPreferencesDemoState createState() => SharedPreferencesDemoState(); @@ -32,7 +32,7 @@ class SharedPreferencesDemo extends StatefulWidget { class SharedPreferencesDemoState extends State { Future _prefs = SharedPreferences.getInstance(); - Future _counter; + late Future _counter; Future _incrementCounter() async { final SharedPreferences prefs = await _prefs; diff --git a/packages/shared_preferences/example/pubspec.yaml b/packages/shared_preferences/example/pubspec.yaml index 272355114..f8d2e5c46 100644 --- a/packages/shared_preferences/example/pubspec.yaml +++ b/packages/shared_preferences/example/pubspec.yaml @@ -5,14 +5,17 @@ publish_to: 'none' dependencies: flutter: sdk: flutter - shared_preferences: ^0.5.12+4 + shared_preferences: ^2.0.5 shared_preferences_tizen: path: ../ dev_dependencies: flutter_driver: sdk: flutter - integration_test: ^1.0.1 + flutter_test: + sdk: flutter + integration_test: + sdk: flutter integration_test_tizen: path: ../../integration_test/ @@ -20,5 +23,5 @@ flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/shared_preferences/example/test_driver/integration_test.dart b/packages/shared_preferences/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/shared_preferences/example/test_driver/integration_test.dart +++ b/packages/shared_preferences/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/shared_preferences/lib/shared_preferences_tizen.dart b/packages/shared_preferences/lib/shared_preferences_tizen.dart index cdc629ef3..4cac02e4c 100644 --- a/packages/shared_preferences/lib/shared_preferences_tizen.dart +++ b/packages/shared_preferences/lib/shared_preferences_tizen.dart @@ -4,6 +4,7 @@ import 'dart:async'; import 'dart:ffi'; + import 'package:ffi/ffi.dart'; import 'package:shared_preferences_platform_interface/shared_preferences_platform_interface.dart'; @@ -13,59 +14,60 @@ import 'src/bindings.dart'; /// /// This class implements the `package:shared_preferences` functionality for Tizen. class SharedPreferencesPlugin extends SharedPreferencesStorePlatform { + /// Registers this class as the default instance of [SharedPreferencesStorePlatform]. static void register() { SharedPreferencesStorePlatform.instance = SharedPreferencesPlugin(); } - static Map _cachedPreferences; + static Map? _cachedPreferences; static const String _separator = '␞'; static int _preferenceItemCallback(Pointer pKey, Pointer data) { - final String key = Utf8.fromUtf8(pKey); + final String key = pKey.toDartString(); int ret; - final Pointer pBool = allocate(); + final Pointer pBool = malloc(); ret = bindings.getBoolean(pKey, pBool); final bool boolValue = pBool.value == 1; - free(pBool); + malloc.free(pBool); if (ret == 0) { - _cachedPreferences[key] = boolValue; + _cachedPreferences![key] = boolValue; return 1; } - final Pointer pDouble = allocate(); + final Pointer pDouble = malloc(); ret = bindings.getDouble(pKey, pDouble); final double doubleValue = pDouble.value; - free(pDouble); + malloc.free(pDouble); if (ret == 0) { - _cachedPreferences[key] = doubleValue; + _cachedPreferences![key] = doubleValue; return 1; } - final Pointer pInt = allocate(); + final Pointer pInt = malloc(); ret = bindings.getInt(pKey, pInt); final int intValue = pInt.value; - free(pInt); + malloc.free(pInt); if (ret == 0) { - _cachedPreferences[key] = intValue; + _cachedPreferences![key] = intValue; return 1; } - final Pointer> ppString = allocate(); + final Pointer> ppString = malloc(); ret = bindings.getString(pKey, ppString); final Pointer pString = ppString.value; - free(ppString); + malloc.free(ppString); if (ret == 0) { // The value could be either String or StringList. For details, see // setValue(). - final String stringValue = Utf8.fromUtf8(pString); + final String stringValue = pString.toDartString(); if (stringValue == _separator) { - _cachedPreferences[key] = []; + _cachedPreferences![key] = []; } else if (stringValue.contains(_separator)) { final List list = stringValue.split(_separator); - _cachedPreferences[key] = list.getRange(1, list.length - 1); + _cachedPreferences![key] = list.getRange(1, list.length - 1); } else { - _cachedPreferences[key] = stringValue; + _cachedPreferences![key] = stringValue; } return 1; } @@ -75,14 +77,14 @@ class SharedPreferencesPlugin extends SharedPreferencesStorePlatform { Map get _preferences { if (_cachedPreferences != null) { - return _cachedPreferences; + return _cachedPreferences!; } _cachedPreferences = {}; final int ret = bindings.foreachItem( Pointer.fromFunction(_preferenceItemCallback, 0), nullptr); if (ret == 0) { - return _cachedPreferences; + return _cachedPreferences!; } return {}; } @@ -101,14 +103,14 @@ class SharedPreferencesPlugin extends SharedPreferencesStorePlatform { Future remove(String key) async { _preferences.remove(key); - return bindings.remove(Utf8.toUtf8(key)) == 0; + return bindings.remove(key.toNativeUtf8()) == 0; } @override Future setValue(String valueType, String key, Object value) async { _preferences[key] = value; - final Pointer pKey = Utf8.toUtf8(key); + final Pointer pKey = key.toNativeUtf8(); int ret; if (valueType == 'Bool') { ret = bindings.setBoolean(pKey, (value as bool) ? 1 : 0); @@ -117,7 +119,7 @@ class SharedPreferencesPlugin extends SharedPreferencesStorePlatform { } else if (valueType == 'Int') { ret = bindings.setInt(pKey, value as int); } else if (valueType == 'String') { - ret = bindings.setString(pKey, Utf8.toUtf8(value as String)); + ret = bindings.setString(pKey, (value as String).toNativeUtf8()); } else if (valueType == 'StringList') { // Tizen Preference API doesn't support arrays. final List list = value as List; @@ -127,9 +129,10 @@ class SharedPreferencesPlugin extends SharedPreferencesStorePlatform { } else { joined = _separator + list.join(_separator) + _separator; } - ret = bindings.setString(pKey, Utf8.toUtf8(joined)); + ret = bindings.setString(pKey, joined.toNativeUtf8()); } else { print('Not implemented : valueType[' + valueType + ']'); + ret = -1; } return ret == 0; } diff --git a/packages/shared_preferences/lib/src/bindings.dart b/packages/shared_preferences/lib/src/bindings.dart index 7e477cb33..c7d67c916 100644 --- a/packages/shared_preferences/lib/src/bindings.dart +++ b/packages/shared_preferences/lib/src/bindings.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: public_member_api_docs + import 'dart:ffi'; import 'types.dart'; @@ -33,9 +35,6 @@ class _PreferenceBindings { remove = _lib.lookupFunction( 'preference_remove'); - isExisting = _lib.lookupFunction('preference_is_existing'); - removeAll = _lib.lookupFunction('preference_remove_all'); @@ -43,20 +42,19 @@ class _PreferenceBindings { PreferenceForeachItem>('preference_foreach_item'); } - DynamicLibrary _lib; - PreferenceSetInt setInt; - PreferenceGetInt getInt; - PreferenceSetDouble setDouble; - PreferenceGetDouble getDouble; - PreferenceSetString setString; - PreferenceGetString getString; - PreferenceSetBoolean setBoolean; - PreferenceGetBoolean getBoolean; - PreferenceRemove remove; - PreferenceIsExisiting isExisting; - PreferenceRemoveAll removeAll; - PreferenceForeachItem foreachItem; + late DynamicLibrary _lib; + late PreferenceSetInt setInt; + late PreferenceGetInt getInt; + late PreferenceSetDouble setDouble; + late PreferenceGetDouble getDouble; + late PreferenceSetString setString; + late PreferenceGetString getString; + late PreferenceSetBoolean setBoolean; + late PreferenceGetBoolean getBoolean; + late PreferenceRemove remove; + late PreferenceRemoveAll removeAll; + late PreferenceForeachItem foreachItem; } -_PreferenceBindings _cachedBindings; +_PreferenceBindings? _cachedBindings; _PreferenceBindings get bindings => _cachedBindings ??= _PreferenceBindings(); diff --git a/packages/shared_preferences/lib/src/types.dart b/packages/shared_preferences/lib/src/types.dart index c132d6a92..b3f5ba15f 100644 --- a/packages/shared_preferences/lib/src/types.dart +++ b/packages/shared_preferences/lib/src/types.dart @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: public_member_api_docs + import 'dart:ffi'; + import 'package:ffi/ffi.dart'; // int preference_set_int (const char *key, int value) @@ -54,12 +57,6 @@ typedef PreferenceGetBoolean = int Function( typedef preference_remove_native_t = Int32 Function(Pointer key); typedef PreferenceRemove = int Function(Pointer key); -// int preference_is_existing (const char *key, bool *existing) -typedef preference_is_existing_native_t = Int32 Function( - Pointer key, Pointer existing); -typedef PreferenceIsExisiting = int Function( - Pointer key, Pointer existing); - // int preference_remove_all (void) typedef preference_remove_all_native_t = Int32 Function(); typedef PreferenceRemoveAll = int Function(); diff --git a/packages/shared_preferences/pubspec.yaml b/packages/shared_preferences/pubspec.yaml index c56a6763f..b67819b1a 100644 --- a/packages/shared_preferences/pubspec.yaml +++ b/packages/shared_preferences/pubspec.yaml @@ -1,6 +1,6 @@ name: shared_preferences_tizen description: Tizen implementation of the shared_preferences plugin -version: 1.0.1 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -11,15 +11,11 @@ flutter: fileName: shared_preferences_tizen.dart dependencies: + ffi: ^1.0.0 flutter: sdk: flutter - shared_preferences_platform_interface: ^1.0.4 - ffi: ^0.1.3 - -dev_dependencies: - flutter_test: - sdk: flutter + shared_preferences_platform_interface: ^2.0.0 environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: '>=2.12.0 <3.0.0' + flutter: ">=2.0.0" diff --git a/packages/url_launcher/CHANGELOG.md b/packages/url_launcher/CHANGELOG.md index efe12ef7e..0c76196f0 100644 --- a/packages/url_launcher/CHANGELOG.md +++ b/packages/url_launcher/CHANGELOG.md @@ -17,3 +17,13 @@ * Use `PlatformException` instead of a plugin-specific exception type (`AppControlException`) * Move `app_control.dart` to the implementation directory + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Update platform interface to 2.0.2 +* Organize dev_dependencies +* Migrate to ffi 1.0.0 +* Migrate to null safety diff --git a/packages/url_launcher/LICENSE b/packages/url_launcher/LICENSE index 4e5cfe14e..5eee0ec43 100644 --- a/packages/url_launcher/LICENSE +++ b/packages/url_launcher/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2017 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/url_launcher/README.md b/packages/url_launcher/README.md index c751445e9..cc08272a3 100644 --- a/packages/url_launcher/README.md +++ b/packages/url_launcher/README.md @@ -8,8 +8,8 @@ This package is not an _endorsed_ implementation of `url_launcher`. Therefore, y ```yaml dependencies: - url_launcher: ^5.7.10 - url_launcher_tizen: ^1.0.3 + url_launcher: ^6.0.2 + url_launcher_tizen: ^2.0.0 ``` Then you can import `url_launcher` in your Dart code: diff --git a/packages/url_launcher/example/integration_test/url_launcher_test.dart b/packages/url_launcher/example/integration_test/url_launcher_test.dart index 785b58c6c..933a3c0ed 100644 --- a/packages/url_launcher/example/integration_test/url_launcher_test.dart +++ b/packages/url_launcher/example/integration_test/url_launcher_test.dart @@ -1,7 +1,10 @@ -// Copyright 2019 the Chromium project authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// TODO(egarciad): Remove once integration_test is migrated to null safety. +// @dart = 2.9 + import 'dart:io' show Platform; import 'package:flutter/foundation.dart' show kIsWeb; @@ -12,7 +15,7 @@ import 'package:url_launcher/url_launcher.dart'; void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - test('canLaunch', () async { + testWidgets('canLaunch', (WidgetTester _) async { expect(await canLaunch('randomstring'), false); // Generally all devices should have some default browser. diff --git a/packages/url_launcher/example/lib/main.dart b/packages/url_launcher/example/lib/main.dart index f7d90c4be..9c0f59ebe 100644 --- a/packages/url_launcher/example/lib/main.dart +++ b/packages/url_launcher/example/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,13 +21,13 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(title: 'URL Launcher'), + home: const MyHomePage(title: 'URL Launcher'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @override @@ -35,7 +35,7 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - Future _launched; + Future? _launched; String _phone = ''; Future _launchInBrowser(String url) async { @@ -141,7 +141,7 @@ class _MyHomePageState extends State { decoration: const InputDecoration( hintText: 'Input the phone number to launch')), ), - RaisedButton( + ElevatedButton( onPressed: () => setState(() { _launched = _makePhoneCall('tel:$_phone'); }), @@ -151,33 +151,33 @@ class _MyHomePageState extends State { padding: EdgeInsets.all(16.0), child: Text(toLaunch), ), - RaisedButton( + ElevatedButton( onPressed: () => setState(() { _launched = _launchInBrowser(toLaunch); }), child: const Text('Launch in browser'), ), const Padding(padding: EdgeInsets.all(16.0)), - RaisedButton( + ElevatedButton( onPressed: () => setState(() { _launched = _launchInWebViewOrVC(toLaunch); }), child: const Text('Launch in app'), ), - RaisedButton( + ElevatedButton( onPressed: () => setState(() { _launched = _launchInWebViewWithJavaScript(toLaunch); }), child: const Text('Launch in app(JavaScript ON)'), ), - RaisedButton( + ElevatedButton( onPressed: () => setState(() { _launched = _launchInWebViewWithDomStorage(toLaunch); }), child: const Text('Launch in app(DOM storage ON)'), ), const Padding(padding: EdgeInsets.all(16.0)), - RaisedButton( + ElevatedButton( onPressed: () => setState(() { _launched = _launchUniversalLinkIos(toLaunch); }), @@ -185,7 +185,7 @@ class _MyHomePageState extends State { 'Launch a universal link in a native app, fallback to Safari.(Youtube)'), ), const Padding(padding: EdgeInsets.all(16.0)), - RaisedButton( + ElevatedButton( onPressed: () => setState(() { _launched = _launchInWebViewOrVC(toLaunch); Timer(const Duration(seconds: 5), () { diff --git a/packages/url_launcher/example/pubspec.yaml b/packages/url_launcher/example/pubspec.yaml index 5746f9ba9..3ba75704a 100644 --- a/packages/url_launcher/example/pubspec.yaml +++ b/packages/url_launcher/example/pubspec.yaml @@ -5,20 +5,23 @@ publish_to: 'none' dependencies: flutter: sdk: flutter - url_launcher: ^5.7.10 + url_launcher: ^6.0.2 url_launcher_tizen: path: ../ dev_dependencies: - integration_test: ^1.0.1 - integration_test_tizen: - path: ../../integration_test/ flutter_driver: sdk: flutter + flutter_test: + sdk: flutter + integration_test: + sdk: flutter + integration_test_tizen: + path: ../../integration_test/ flutter: uses-material-design: true environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.22.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/url_launcher/example/test_driver/integration_test.dart b/packages/url_launcher/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/url_launcher/example/test_driver/integration_test.dart +++ b/packages/url_launcher/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/url_launcher/lib/src/app_control.dart b/packages/url_launcher/lib/src/app_control.dart index c66ad7c4a..477c41652 100644 --- a/packages/url_launcher/lib/src/app_control.dart +++ b/packages/url_launcher/lib/src/app_control.dart @@ -2,31 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// ignore_for_file: public_member_api_docs + import 'dart:ffi'; import 'package:ffi/ffi.dart'; import 'package:flutter/services.dart'; -// Native function signatures -typedef app_control_create = Int32 Function(Pointer>); -typedef app_control_set_operation = Int32 Function( +typedef _app_control_create = Int32 Function(Pointer>); +typedef _app_control_set_operation = Int32 Function( Pointer<_AppControl>, Pointer); -typedef app_control_set_uri = Int32 Function( +typedef _app_control_set_uri = Int32 Function( Pointer<_AppControl>, Pointer); -typedef app_control_send_launch_request = Int32 Function( +typedef _app_control_send_launch_request = Int32 Function( Pointer<_AppControl>, Pointer, Pointer); -typedef app_control_destroy = Int32 Function(Pointer<_AppControl>); +typedef _app_control_destroy = Int32 Function(Pointer<_AppControl>); -// Constants from [app_control_result_e] in `app_control.h` +// Corresponds to `app_control_result_e` in `app_control.h` const int APP_CONTROL_RESULT_APP_STARTED = 1; const int APP_CONTROL_RESULT_SUCCEEDED = 0; const int APP_CONTROL_RESULT_FAILED = -1; const int APP_CONTROL_RESULT_CANCELED = -2; -// Constant from `app_control.h` +// Corresponds to constants defined in `app_control.h` const String APP_CONTROL_OPERATION_VIEW = 'http://tizen.org/appcontrol/operation/view'; -// Constants from `tizen_error.h` +// Corresponds to constants defined in `tizen_error.h` const int TIZEN_ERROR_NONE = 0; const int TIZEN_ERROR_INVALID_PARAMETER = -22; const int TIZEN_ERROR_OUT_OF_MEMORY = -12; @@ -37,10 +38,10 @@ const int TIZEN_ERROR_PERMISSION_DENIED = -13; const int TIZEN_ERROR_TIMED_OUT = -1073741824 + 1; const int TIZEN_ERROR_IO_ERROR = -5; -class _AppControl extends Struct {} +class _AppControl extends Opaque {} -// Constants from [app_control_error_e] in `app_control.h` -const Map errorCodes = { +/// Corresponds to `app_control_error_e` in `app_control.h` +const Map _errorCodes = { TIZEN_ERROR_NONE: 'APP_CONTROL_ERROR_NONE', TIZEN_ERROR_INVALID_PARAMETER: 'APP_CONTROL_ERROR_INVALID_PARAMETER', TIZEN_ERROR_OUT_OF_MEMORY: 'APP_CONTROL_ERROR_OUT_OF_MEMORY', @@ -55,102 +56,104 @@ const Map errorCodes = { TIZEN_ERROR_IO_ERROR: 'APP_CONTROL_ERROR_IO_ERROR', }; -String getErrorCode(int returnCode) => - errorCodes.containsKey(returnCode) ? errorCodes[returnCode] : '$returnCode'; +String _getErrorCode(int returnCode) => _errorCodes.containsKey(returnCode) + ? _errorCodes[returnCode]! + : '$returnCode'; -/// A wrapper class of the native App Control API. -/// Not all functions or values are supported. +/// Dart wrapper of Tizen's `app_control`. +/// +/// See: https://docs.tizen.org/application/native/api/wearable/latest/group__CAPI__APP__CONTROL__MODULE.html class AppControl { AppControl() { final DynamicLibrary lib = DynamicLibrary.open('libcapi-appfw-app-control.so.0'); _create = lib - .lookup>('app_control_create') + .lookup>('app_control_create') .asFunction(); _setOperation = lib - .lookup>( + .lookup>( 'app_control_set_operation') .asFunction(); _setUri = lib - .lookup>('app_control_set_uri') + .lookup>('app_control_set_uri') .asFunction(); _sendLaunchRequest = lib - .lookup>( + .lookup>( 'app_control_send_launch_request') .asFunction(); _destroy = lib - .lookup>('app_control_destroy') + .lookup>('app_control_destroy') .asFunction(); } - // Bindings - int Function(Pointer>) _create; - int Function(Pointer<_AppControl>, Pointer) _setOperation; - int Function(Pointer<_AppControl>, Pointer) _setUri; - int Function(Pointer<_AppControl>, Pointer, Pointer) + late int Function(Pointer>) _create; + late int Function(Pointer<_AppControl>, Pointer) _setOperation; + late int Function(Pointer<_AppControl>, Pointer) _setUri; + late int Function(Pointer<_AppControl>, Pointer, Pointer) _sendLaunchRequest; - int Function(Pointer<_AppControl>) _destroy; - - Pointer<_AppControl> _handle; + late int Function(Pointer<_AppControl>) _destroy; - bool get isValid => _handle != null; + Pointer<_AppControl> _handle = nullptr; + /// Corresponds to `app_control_create()`. void create() { - final Pointer> pHandle = allocate(); + final Pointer> pHandle = malloc(); final int ret = _create(pHandle); _handle = pHandle.value; - free(pHandle); + malloc.free(pHandle); if (ret != 0) { throw PlatformException( - code: getErrorCode(ret), + code: _getErrorCode(ret), message: 'Failed to execute app_control_create.', ); } } + /// Corresponds to `app_control_set_operation()`. void setOperation(String operation) { - assert(isValid); + assert(_handle != nullptr); - final int ret = _setOperation(_handle, Utf8.toUtf8(operation)); + final int ret = _setOperation(_handle, operation.toNativeUtf8()); if (ret != 0) { throw PlatformException( - code: getErrorCode(ret), + code: _getErrorCode(ret), message: 'Failed to execute app_control_set_operation.', ); } } + /// Corresponds to `app_control_set_uri()`. void setUri(String uri) { - assert(isValid); + assert(_handle != nullptr); - final int ret = _setUri(_handle, Utf8.toUtf8(uri)); + final int ret = _setUri(_handle, uri.toNativeUtf8()); if (ret != 0) { throw PlatformException( - code: getErrorCode(ret), + code: _getErrorCode(ret), message: 'Failed to execute app_control_set_uri.', ); } } + /// Corresponds to `app_control_send_launch_request()`. void sendLaunchRequest() { - assert(isValid); + assert(_handle != nullptr); final int ret = _sendLaunchRequest(_handle, nullptr, nullptr); if (ret != 0) { throw PlatformException( - code: getErrorCode(ret), + code: _getErrorCode(ret), message: 'Failed to execute app_control_send_launch_request.', ); } } - /// This method must be called after use to release the underlying handle. - /// `dart:ffi` doesn't support finalizers (the disposal pattern) as of now. + /// Corresponds to `app_control_destroy()`. void destroy() { - if (isValid) { + if (_handle != nullptr) { _destroy(_handle); - _handle = null; + _handle = nullptr; } } } diff --git a/packages/url_launcher/lib/url_launcher_tizen.dart b/packages/url_launcher/lib/url_launcher_tizen.dart index bf9dcef4e..7e4702b0c 100644 --- a/packages/url_launcher/lib/url_launcher_tizen.dart +++ b/packages/url_launcher/lib/url_launcher_tizen.dart @@ -4,12 +4,12 @@ import 'dart:async'; -import 'package:meta/meta.dart'; import 'package:url_launcher_platform_interface/link.dart'; import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; import 'src/app_control.dart'; +/// The Tizen implementation of [UrlLauncherPlatform]. class UrlLauncherPlugin extends UrlLauncherPlatform { static final Set _supportedSchemes = { 'file', @@ -23,9 +23,9 @@ class UrlLauncherPlugin extends UrlLauncherPlatform { } @override - final LinkDelegate linkDelegate = null; + final LinkDelegate? linkDelegate = null; - String _getUrlScheme(String url) => Uri.tryParse(url)?.scheme; + String? _getUrlScheme(String url) => Uri.tryParse(url)?.scheme; @override Future canLaunch(String url) async { @@ -35,24 +35,20 @@ class UrlLauncherPlugin extends UrlLauncherPlatform { @override Future launch( String url, { - @required bool useSafariVC, - @required bool useWebView, - @required bool enableJavaScript, - @required bool enableDomStorage, - @required bool universalLinksOnly, - @required Map headers, - String webOnlyWindowName, + required bool useSafariVC, + required bool useWebView, + required bool enableJavaScript, + required bool enableDomStorage, + required bool universalLinksOnly, + required Map headers, + String? webOnlyWindowName, }) async { - AppControl appControl; - try { - appControl = AppControl() - ..create() - ..setOperation(APP_CONTROL_OPERATION_VIEW) - ..setUri(url) - ..sendLaunchRequest(); - return true; - } finally { - appControl?.destroy(); - } + AppControl() + ..create() + ..setOperation(APP_CONTROL_OPERATION_VIEW) + ..setUri(url) + ..sendLaunchRequest() + ..destroy(); + return true; } } diff --git a/packages/url_launcher/pubspec.yaml b/packages/url_launcher/pubspec.yaml index a1970afb4..7c6d5f719 100644 --- a/packages/url_launcher/pubspec.yaml +++ b/packages/url_launcher/pubspec.yaml @@ -1,7 +1,7 @@ name: url_launcher_tizen description: Tizen implementation of the url_launcher plugin homepage: https://github.com/flutter-tizen/plugins -version: 1.0.3 +version: 2.0.0 flutter: plugin: @@ -11,19 +11,11 @@ flutter: fileName: url_launcher_tizen.dart dependencies: + ffi: ^1.0.0 flutter: sdk: flutter - url_launcher_platform_interface: ^1.0.9 - ffi: ^0.1.3 - meta: ^1.1.7 - -dev_dependencies: - test: ^1.3.0 - flutter_test: - sdk: flutter - mockito: ^4.1.1 - url_launcher: ^5.7.10 + url_launcher_platform_interface: ^2.0.2 environment: - sdk: ">=2.2.2 <3.0.0" - flutter: ">=1.22.0 <2.0.0" + sdk: '>=2.12.0 <3.0.0' + flutter: ">=2.0.0" diff --git a/packages/wifi_info_flutter/CHANGELOG.md b/packages/wifi_info_flutter/CHANGELOG.md index 32f490b5f..c2a18af04 100644 --- a/packages/wifi_info_flutter/CHANGELOG.md +++ b/packages/wifi_info_flutter/CHANGELOG.md @@ -1,3 +1,11 @@ ## 1.0.0 * Initial release + +## 2.0.0 + +* Update Dart and Flutter SDK constraints +* Update Flutter copyright information +* Update example and integration_test +* Update platform interface to 2.0.1 +* Organize dev_dependencies diff --git a/packages/wifi_info_flutter/LICENSE b/packages/wifi_info_flutter/LICENSE index 6ae330dee..29b9b9d1e 100644 --- a/packages/wifi_info_flutter/LICENSE +++ b/packages/wifi_info_flutter/LICENSE @@ -1,5 +1,5 @@ Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved. -Copyright (c) 2020 The Chromium Authors. All rights reserved. +Copyright (c) 2013 The Flutter Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/packages/wifi_info_flutter/README.md b/packages/wifi_info_flutter/README.md index 62d3ea144..f774808eb 100644 --- a/packages/wifi_info_flutter/README.md +++ b/packages/wifi_info_flutter/README.md @@ -8,8 +8,8 @@ This package is not an _endorsed_ implementation of `wifi_info_flutter`. Therefo ```yaml dependencies: - wifi_info_flutter: ^1.0.1 - wifi_info_flutter_tizen: ^1.0.0 + wifi_info_flutter: ^2.0.0 + wifi_info_flutter_tizen: ^2.0.0 ``` Then you can import `wifi_info_flutter` in your Dart code: diff --git a/packages/wifi_info_flutter/example/README.md b/packages/wifi_info_flutter/example/README.md index 5465eabbb..2d43a13d8 100644 --- a/packages/wifi_info_flutter/example/README.md +++ b/packages/wifi_info_flutter/example/README.md @@ -1,4 +1,4 @@ -# wifi_info_flutter_example +# wifi_info_flutter_tizen_example Demonstrates how to use the wifi_info_flutter_tizen plugin. diff --git a/packages/wifi_info_flutter/example/integration_test/wifi_info_test.dart b/packages/wifi_info_flutter/example/integration_test/wifi_info_test.dart index 103dc54a1..4f07fe4a0 100644 --- a/packages/wifi_info_flutter/example/integration_test/wifi_info_test.dart +++ b/packages/wifi_info_flutter/example/integration_test/wifi_info_test.dart @@ -1,7 +1,9 @@ -// Copyright 2020 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// @dart = 2.9 + import 'dart:io'; import 'package:integration_test/integration_test.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -19,7 +21,7 @@ void main() { testWidgets('test location methods, iOS only', (WidgetTester tester) async { expect( - (await _wifiInfo.getLocationServiceAuthorization()), + await _wifiInfo.getLocationServiceAuthorization(), LocationAuthorizationStatus.notDetermined, ); }, skip: !Platform.isIOS); diff --git a/packages/wifi_info_flutter/example/lib/main.dart b/packages/wifi_info_flutter/example/lib/main.dart index 8c64c5d9a..9320bd156 100644 --- a/packages/wifi_info_flutter/example/lib/main.dart +++ b/packages/wifi_info_flutter/example/lib/main.dart @@ -1,4 +1,4 @@ -// Copyright 2020 The Chromium Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,13 +36,13 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(title: 'Flutter Demo Home Page'), + home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); + const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @@ -54,7 +54,7 @@ class _MyHomePageState extends State { String _connectionStatus = 'Unknown'; final Connectivity _connectivity = Connectivity(); final WifiInfo _wifiInfo = WifiInfo(); - StreamSubscription _connectivitySubscription; + late StreamSubscription _connectivitySubscription; @override void initState() { @@ -72,7 +72,7 @@ class _MyHomePageState extends State { // Platform messages are asynchronous, so we initialize in an async method. Future initConnectivity() async { - ConnectivityResult result; + late ConnectivityResult result; // Platform messages may fail, so we use a try/catch PlatformException. try { result = await _connectivity.checkConnectivity(); @@ -84,7 +84,7 @@ class _MyHomePageState extends State { // message was in flight, we want to discard the reply rather than calling // setState to update our non-existent appearance. if (!mounted) { - return Future.value(null); + return; } return _updateConnectionStatus(result); @@ -103,7 +103,7 @@ class _MyHomePageState extends State { Future _updateConnectionStatus(ConnectivityResult result) async { switch (result) { case ConnectivityResult.wifi: - String wifiName, wifiBSSID, wifiIP; + String? wifiName, wifiBSSID, wifiIP; try { if (!kIsWeb && Platform.isIOS) { @@ -123,7 +123,7 @@ class _MyHomePageState extends State { } } on PlatformException catch (e) { print(e.toString()); - wifiName = "Failed to get Wifi Name"; + wifiName = 'Failed to get Wifi Name'; } try { @@ -144,14 +144,14 @@ class _MyHomePageState extends State { } } on PlatformException catch (e) { print(e.toString()); - wifiBSSID = "Failed to get Wifi BSSID"; + wifiBSSID = 'Failed to get Wifi BSSID'; } try { wifiIP = await _wifiInfo.getWifiIP(); } on PlatformException catch (e) { print(e.toString()); - wifiIP = "Failed to get Wifi IP"; + wifiIP = 'Failed to get Wifi IP'; } setState(() { diff --git a/packages/wifi_info_flutter/example/pubspec.yaml b/packages/wifi_info_flutter/example/pubspec.yaml index f688c8b4f..34b4aae2e 100644 --- a/packages/wifi_info_flutter/example/pubspec.yaml +++ b/packages/wifi_info_flutter/example/pubspec.yaml @@ -3,26 +3,26 @@ description: Demonstrates how to use the wifi_info_flutter_tizen plugin. publish_to: 'none' dependencies: - connectivity: ^2.0.2 + connectivity: ^3.0.3 connectivity_tizen: path: ../../connectivity/ - cupertino_icons: ^1.0.0 flutter: sdk: flutter - integration_test: ^1.0.1 - integration_test_tizen: - path: ../../integration_test/ - wifi_info_flutter: ^1.0.1 + wifi_info_flutter: ^2.0.0 wifi_info_flutter_tizen: path: ../ dev_dependencies: flutter_test: sdk: flutter + integration_test: + sdk: flutter + integration_test_tizen: + path: ../../integration_test/ flutter: uses-material-design: true environment: - sdk: ">=2.7.0 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0" diff --git a/packages/wifi_info_flutter/example/test_driver/integration_test.dart b/packages/wifi_info_flutter/example/test_driver/integration_test.dart index b38629cca..0603ed6f7 100644 --- a/packages/wifi_info_flutter/example/test_driver/integration_test.dart +++ b/packages/wifi_info_flutter/example/test_driver/integration_test.dart @@ -1,3 +1,5 @@ +// @dart=2.9 + import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); diff --git a/packages/wifi_info_flutter/pubspec.yaml b/packages/wifi_info_flutter/pubspec.yaml index 63b32a072..d8c001ee8 100644 --- a/packages/wifi_info_flutter/pubspec.yaml +++ b/packages/wifi_info_flutter/pubspec.yaml @@ -1,6 +1,6 @@ name: wifi_info_flutter_tizen description: Tizen implementation of the wifi_info_flutter plugin -version: 1.0.0 +version: 2.0.0 homepage: https://github.com/flutter-tizen/plugins flutter: @@ -13,13 +13,8 @@ flutter: dependencies: flutter: sdk: flutter - wifi_info_flutter_platform_interface: ^1.0.0 - -dev_dependencies: - flutter_test: - sdk: flutter - plugin_platform_interface: ^1.0.0 + wifi_info_flutter_platform_interface: ^2.0.1 environment: - sdk: ">=2.7.0 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: ">=2.0.0"