From 05a3610c048f2dc06120202710d5f43296f50fa5 Mon Sep 17 00:00:00 2001 From: Pierre Date: Thu, 30 Jun 2022 20:29:42 +0200 Subject: [PATCH 1/2] upgradde deps --- example/pubspec.lock | 34 ++++++++++++++-------------- pubspec.lock | 53 +++++++++++++++++++++++++------------------- pubspec.yaml | 4 ++-- 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 486f161..4f50e99 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -42,7 +42,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: @@ -82,7 +82,7 @@ packages: path: ".." relative: true source: path - version: "0.1.5" + version: "0.1.7" flutter_test: dependency: "direct dev" description: flutter @@ -94,7 +94,7 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.1.1" + version: "4.5.0" matcher: dependency: transitive description: @@ -102,6 +102,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" meta: dependency: transitive description: @@ -115,7 +122,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider: dependency: "direct main" description: @@ -178,7 +185,7 @@ packages: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.26.0" + version: "0.27.4" sky_engine: dependency: transitive description: flutter @@ -190,7 +197,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -225,21 +232,14 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" + version: "0.4.9" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" win32: dependency: transitive description: @@ -255,5 +255,5 @@ packages: source: hosted version: "0.1.2" sdks: - dart: ">=2.13.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.20.0" diff --git a/pubspec.lock b/pubspec.lock index e2e6f12..f2f1a35 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "14.0.0" + version: "22.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.41.2" + version: "1.7.2" args: dependency: transitive description: @@ -42,14 +42,14 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" + version: "2.0.3" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.6" + version: "0.4.7" build_daemon: dependency: transitive description: @@ -63,21 +63,21 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.5.3" + version: "2.0.4" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.11.5" + version: "1.12.2" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "6.1.10" + version: "6.1.12" built_collection: dependency: transitive description: @@ -112,7 +112,7 @@ packages: name: checked_yaml url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.1" cli_util: dependency: transitive description: @@ -140,7 +140,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" convert: dependency: transitive description: @@ -161,14 +161,14 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.12" + version: "2.1.1" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" file: dependency: transitive description: @@ -206,7 +206,7 @@ packages: name: graphs url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "1.0.0" http_multi_server: dependency: transitive description: @@ -241,14 +241,14 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "3.1.1" + version: "4.1.0" json_serializable: dependency: "direct dev" description: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "3.5.1" + version: "4.1.4" logging: dependency: transitive description: @@ -263,6 +263,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.4" meta: dependency: transitive description: @@ -283,14 +290,14 @@ packages: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "2.1.0" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" pedantic: dependency: transitive description: @@ -318,14 +325,14 @@ packages: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "0.1.8" + version: "1.1.0" rxdart: dependency: "direct main" description: name: rxdart url: "https://pub.dartlang.org" source: hosted - version: "0.26.0" + version: "0.27.4" shelf: dependency: transitive description: @@ -351,14 +358,14 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.10+3" + version: "1.0.3" source_span: dependency: transitive description: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -400,7 +407,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.9" timing: dependency: transitive description: @@ -421,7 +428,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.2" watcher: dependency: transitive description: @@ -444,5 +451,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.12.0" diff --git a/pubspec.yaml b/pubspec.yaml index 2ac5afa..f4d114e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,13 +11,13 @@ dependencies: flutter: sdk: flutter json_annotation: ^4.1.0 - rxdart: ^0.26.0 + rxdart: ^0.27.3 dev_dependencies: flutter_test: sdk: flutter build_runner: ^1.0.0 - json_serializable: ^3.2.2 + json_serializable: ^4.0.3 flutter: plugin: From 5858344588ef284f3fc6c823a785cabb0c2b4896 Mon Sep 17 00:00:00 2001 From: pierre Date: Sat, 10 Sep 2022 21:53:51 +0200 Subject: [PATCH 2/2] publish to none --- .../FlutterBluetoothBasicPlugin.java | 40 +++++++++++++++++++ example/lib/main.dart | 6 +-- example/pubspec.lock | 2 +- lib/src/bluetooth_manager.dart | 7 ++++ pubspec.yaml | 3 +- 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/tablemi/flutter_bluetooth_basic/FlutterBluetoothBasicPlugin.java b/android/src/main/java/com/tablemi/flutter_bluetooth_basic/FlutterBluetoothBasicPlugin.java index 3eca57f..2c98fd9 100644 --- a/android/src/main/java/com/tablemi/flutter_bluetooth_basic/FlutterBluetoothBasicPlugin.java +++ b/android/src/main/java/com/tablemi/flutter_bluetooth_basic/FlutterBluetoothBasicPlugin.java @@ -87,6 +87,46 @@ public void onMethodCall(MethodCall call, Result result) { break; case "isConnected": result.success(threadPool != null); + break; + case "getBondedDevices": + try { + + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + + if (ContextCompat.checkSelfPermission(activity, + Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED || + ContextCompat.checkSelfPermission(activity, + Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED || + ContextCompat.checkSelfPermission(activity, + Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + + ActivityCompat.requestPermissions(activity,new String[]{ + Manifest.permission.BLUETOOTH_SCAN, + Manifest.permission.BLUETOOTH_CONNECT, + Manifest.permission.ACCESS_FINE_LOCATION, + }, 1); + + pendingResult = result; + break; + } + } else { + if (ContextCompat.checkSelfPermission(activity, + Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED||ContextCompat.checkSelfPermission(activity, + Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + + ActivityCompat.requestPermissions(activity, + new String[] { Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_COARSE_LOCATION_PERMISSIONS); + + pendingResult = result; + break; + } + } + getBondedDevices(result); + + } catch (Exception ex) { + result.error("Error", ex.getMessage(), exceptionToString(ex)); + } + break; case "startScan": { if (ContextCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_COARSE_LOCATION) diff --git a/example/lib/main.dart b/example/lib/main.dart index 36e2042..c4bbb46 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -157,18 +157,18 @@ class _MyHomePageState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - OutlineButton( + ElevatedButton( child: Text('connect'), onPressed: _connected ? null : _onConnect, ), SizedBox(width: 10.0), - OutlineButton( + ElevatedButton( child: Text('disconnect'), onPressed: _connected ? _onDisconnect : null, ), ], ), - OutlineButton( + ElevatedButton( child: Text('Send test data'), onPressed: _connected ? _sendData : null, ), diff --git a/example/pubspec.lock b/example/pubspec.lock index 4f50e99..7117e44 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -82,7 +82,7 @@ packages: path: ".." relative: true source: path - version: "0.1.7" + version: "0.1.8" flutter_test: dependency: "direct dev" description: flutter diff --git a/lib/src/bluetooth_manager.dart b/lib/src/bluetooth_manager.dart index e67bc24..0542d23 100644 --- a/lib/src/bluetooth_manager.dart +++ b/lib/src/bluetooth_manager.dart @@ -26,6 +26,13 @@ class BluetoothManager { }); } + // method imported from blue_thermal_printer package + ///getBondedDevices() + Future> getBondedDevices() async { + final List list = await (_channel.invokeMethod('getBondedDevices')); + return list.map((map) => BluetoothDevice.fromJson(map)).toList(); + } + static BluetoothManager _instance = BluetoothManager._(); static BluetoothManager get instance => _instance; diff --git a/pubspec.yaml b/pubspec.yaml index f4d114e..280413a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,8 @@ name: flutter_bluetooth_basic description: Flutter plugin that allows to find bluetooth devices & send raw bytes data -version: 0.1.7 +version: 0.1.8 homepage: https://github.com/andrey-ushakov/flutter_bluetooth_basic +publish_to: none environment: sdk: ">=2.12.0 <3.0.0"