From 5dbd0764f9a3d6000d6a1e0e359325b4034adb59 Mon Sep 17 00:00:00 2001 From: Jeroen1602 <1492076+jeroen1602@users.noreply.github.com> Date: Sun, 27 Mar 2022 18:28:37 +0200 Subject: [PATCH] Updated version to 0.0.7 Added last few missing public api documentation Added web as the only supported platform --- CHANGELOG.md | 6 ++++++ lib/src/bluetooth_characteristic_properties.dart | 7 +++++++ lib/src/flutter_web_bluetooth_interface.dart | 8 ++++++++ lib/src/flutter_web_bluetooth_unsupported.dart | 8 +++++++- lib/web/bluetooth.dart | 13 +++++++++++++ .../web_bluetooth_remote_gatt_characteristic.dart | 2 -- lib/web/web_bluetooth_remote_gatt_service.dart | 3 --- lib/web_bluetooth_logger.dart | 2 +- pubspec.yaml | 5 ++++- 9 files changed, 46 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b24daa4..d9ba390 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.0.7 + +* Added `getCharacteristics` to the bluetooth service to get all the characteristics. +* Set target platform to web for [pub.dev](https://pub.dev/packages/flutter_web_bluetooth/) target platform list (it will still compile when used in non-native programs.) +* Added documentation to the last few public interfaces + ## 0.0.6+2 * Fixed the behavior subject stream not returning the stored value causing some implementations to wait forever. diff --git a/lib/src/bluetooth_characteristic_properties.dart b/lib/src/bluetooth_characteristic_properties.dart index 8a72f04..ba88da3 100644 --- a/lib/src/bluetooth_characteristic_properties.dart +++ b/lib/src/bluetooth_characteristic_properties.dart @@ -9,6 +9,13 @@ part of flutter_web_bluetooth; /// then it will throw a [NotSupportedError]. /// class BluetoothCharacteristicProperties { + /// + /// A constructor for new characteristic properties. + /// + /// **This should only be done by the library or if you're testing.** + /// + /// To get an instance use [BluetoothCharacteristic.properties]. + /// BluetoothCharacteristicProperties(this._properties); final WebBluetoothCharacteristicProperties _properties; diff --git a/lib/src/flutter_web_bluetooth_interface.dart b/lib/src/flutter_web_bluetooth_interface.dart index c64d242..edee6b7 100644 --- a/lib/src/flutter_web_bluetooth_interface.dart +++ b/lib/src/flutter_web_bluetooth_interface.dart @@ -7,6 +7,14 @@ part of flutter_web_bluetooth; /// See: [FlutterWebBluetooth]. /// abstract class FlutterWebBluetoothInterface { + /// + /// An interface for [FlutterWebBluetooth] to make sure that both the + /// unsupported and web version have the same api. + /// + /// See: [FlutterWebBluetooth]. + /// + FlutterWebBluetoothInterface(); + /// /// Get if the bluetooth api is available in this browser. This will only /// check if the api is in the `navigator`. Not if anything is available. diff --git a/lib/src/flutter_web_bluetooth_unsupported.dart b/lib/src/flutter_web_bluetooth_unsupported.dart index 442e46f..0dc3171 100644 --- a/lib/src/flutter_web_bluetooth_unsupported.dart +++ b/lib/src/flutter_web_bluetooth_unsupported.dart @@ -14,8 +14,8 @@ import 'dart:typed_data'; import 'package:flutter_web_bluetooth/js_web_bluetooth.dart'; import 'package:meta/meta.dart'; -import '../web_bluetooth_logger.dart'; import '../shared/web_behavior_subject.dart'; +import '../web_bluetooth_logger.dart'; part 'bluetooth_characteristic.dart'; @@ -61,6 +61,12 @@ class FlutterWebBluetooth extends FlutterWebBluetoothInterface { static FlutterWebBluetooth? _instance; + /// + /// Get an instance of the library. There will always only be one instance. + /// + /// **Note:** this is the unsupported variant that is exposed in io builds, + /// check the web version where the functions actually work! + /// static FlutterWebBluetoothInterface get instance { return _instance ??= FlutterWebBluetooth._(); } diff --git a/lib/web/bluetooth.dart b/lib/web/bluetooth.dart index 00e4b09..6ddcb4f 100644 --- a/lib/web/bluetooth.dart +++ b/lib/web/bluetooth.dart @@ -112,6 +112,19 @@ class _NativeBluetooth { /// @visibleForTesting class NativeBluetooth { + /// + /// Create a new instance of [NativeBluetooth] with the default + /// implementations for the methods that will call the actual methods + /// on the navigator in the background. + /// + /// Using the constructor can be used if you want to rest the native bluetooth + /// implementation for testing using [setNativeBluetooth]. + /// + /// Otherwise the Fake library can be used to overwrite the methods for testing + /// + @visibleForTesting + NativeBluetooth(); + /// /// Should return a promise (which will be converted to a future using /// [JSUtils.promiseToFuture]) with a [bool] if bluetooth is available on diff --git a/lib/web/web_bluetooth_remote_gatt_characteristic.dart b/lib/web/web_bluetooth_remote_gatt_characteristic.dart index d5ef533..6eb5ffe 100644 --- a/lib/web/web_bluetooth_remote_gatt_characteristic.dart +++ b/lib/web/web_bluetooth_remote_gatt_characteristic.dart @@ -6,7 +6,6 @@ part of js_web_bluetooth; /// /// You can get a [WebBluetoothRemoteGATTCharacteristic] from /// [WebBluetoothRemoteGATTService.getCharacteristic], and -/// ignore: deprecated_member_use_from_same_package /// [WebBluetoothRemoteGATTService.getCharacteristics]. /// /// See: @@ -484,7 +483,6 @@ class WebBluetoothRemoteGATTCharacteristic { /// **This should only be done by the library or if you're testing.** /// /// To get an instance use [WebBluetoothRemoteGATTService.getCharacteristic], - /// ignore: deprecated_member_use_from_same_package /// and [WebBluetoothRemoteGATTService.getCharacteristics]. /// WebBluetoothRemoteGATTCharacteristic.fromJSObject( diff --git a/lib/web/web_bluetooth_remote_gatt_service.dart b/lib/web/web_bluetooth_remote_gatt_service.dart index 516617f..af2c8d7 100644 --- a/lib/web/web_bluetooth_remote_gatt_service.dart +++ b/lib/web/web_bluetooth_remote_gatt_service.dart @@ -120,7 +120,6 @@ class WebBluetoothRemoteGATTService { /// /// See: /// - /// ignore: deprecated_member_use_from_same_package /// - [getCharacteristics] /// /// - https://developer.mozilla.org/en-US/docs/Web/API/BluetoothRemoteGATTService/getCharacteristic @@ -136,14 +135,12 @@ class WebBluetoothRemoteGATTService { } /// - /// ignore: deprecated_member_use_from_same_package /// Check to see if the [getCharacteristics] function exists on the js object. /// /// It may not exist on some browsers. /// /// See: /// - /// ignore: deprecated_member_use_from_same_package /// - [getCharacteristics] /// bool hasGetCharacteristicsFunction() { diff --git a/lib/web_bluetooth_logger.dart b/lib/web_bluetooth_logger.dart index 56c782a..5d24c55 100644 --- a/lib/web_bluetooth_logger.dart +++ b/lib/web_bluetooth_logger.dart @@ -28,7 +28,7 @@ Logger get webBluetoothLogger { } /// -/// Overwrite the logger used so you can do decide where the log messages go. +/// Overwrite the logger used so you can decide where the log messages go. /// /// If you want to go back to the default logger at a later date then just call /// [initWebBluetoothLogger] to overwrite the user set logger for the default one. diff --git a/pubspec.yaml b/pubspec.yaml index 0cc9f97..081524a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_web_bluetooth description: A library to use the web bluetooth api in your web project. Will play nice if used in IO projects. -version: 0.0.6+2 +version: 0.0.7 homepage: https://github.com/jeroen1602/flutter_web_bluetooth/ repository: https://github.com/jeroen1602/flutter_web_bluetooth/ issue_tracker: https://github.com/jeroen1602/flutter_web_bluetooth/issues/ @@ -8,6 +8,9 @@ issue_tracker: https://github.com/jeroen1602/flutter_web_bluetooth/issues/ environment: sdk: ">=2.12.0 <3.0.0" +platforms: + web: + dependencies: js: '>=0.6.3 <0.7.0' meta: '>=1.3.0 <1.8.0'