diff --git a/android/build.gradle b/android/build.gradle index 64e247dc..59f9560b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -23,10 +23,10 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { - compileSdkVersion 28 + compileSdkVersion 33 defaultConfig { - minSdkVersion 18 + minSdkVersion 21 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } lintOptions { diff --git a/lib/src/bridge/characteristics_mixin.dart b/lib/src/bridge/characteristics_mixin.dart index 12a80d52..05158c7a 100644 --- a/lib/src/bridge/characteristics_mixin.dart +++ b/lib/src/bridge/characteristics_mixin.dart @@ -26,9 +26,8 @@ mixin CharacteristicsMixin on FlutterBLE { rawJsonValue = rawValue; } return _parseCharacteristicWithValueWithTransactionIdResponse( - peripheral, - rawJsonValue - ).value; + peripheral, rawJsonValue) + .value; }); Future readCharacteristicForDevice( @@ -55,9 +54,7 @@ mixin CharacteristicsMixin on FlutterBLE { rawJsonValue = rawValue; } return _parseCharacteristicWithValueWithTransactionIdResponse( - peripheral, - rawJsonValue - ); + peripheral, rawJsonValue); }); Future readCharacteristicForService( @@ -83,9 +80,7 @@ mixin CharacteristicsMixin on FlutterBLE { rawJsonValue = rawValue; } return _parseCharacteristicWithValueWithTransactionIdResponse( - peripheral, - rawJsonValue - ); + peripheral, rawJsonValue); }); Future writeCharacteristicForIdentifier( @@ -181,7 +176,9 @@ mixin CharacteristicsMixin on FlutterBLE { transactionId, characteristic._transactionId ?? "", ); - }; + } + + ; return _createMonitoringStream( startMonitoring, @@ -259,23 +256,20 @@ mixin CharacteristicsMixin on FlutterBLE { String transactionId, ) { Stream stream = - _characteristicsMonitoringEvents - .map((rawValue) { - String rawJsonValue = ""; - if (rawValue is String) { - rawJsonValue = rawValue; - } - return _parseCharacteristicWithValueWithTransactionIdResponse( - peripheral, - rawJsonValue - ); - }) - .where(filter) - .handleError((errorJson) => - _throwErrorIfMatchesWithTransactionId(errorJson, transactionId)) - .transform( - CancelOnErrorStreamTransformer() - ); + _characteristicsMonitoringEvents + .map((rawValue) { + String rawJsonValue = ""; + if (rawValue is String) { + rawJsonValue = rawValue; + } + return _parseCharacteristicWithValueWithTransactionIdResponse( + peripheral, rawJsonValue); + }) + .where(filter) + .handleError((errorJson) => + _throwErrorIfMatchesWithTransactionId(errorJson, transactionId)) + .transform( + CancelOnErrorStreamTransformer()); StreamController streamController = StreamController.broadcast( @@ -311,7 +305,8 @@ mixin CharacteristicsMixin on FlutterBLE { rootObject["characteristic"], service, _manager); } - void _throwErrorIfMatchesWithTransactionId(PlatformException errorJson, String transactionId) { + void _throwErrorIfMatchesWithTransactionId( + PlatformException errorJson, String transactionId) { if (errorJson is PlatformException == false) { return; } @@ -333,7 +328,8 @@ class CharacteristicWithValueAndTransactionId extends CharacteristicWithValue { ) : super.fromJson(jsonObject, service, manager); CharacteristicWithValueAndTransactionId setTransactionId( - String transactionId) { + String? transactionId, + ) { _transactionId = transactionId; return this; } diff --git a/pubspec.yaml b/pubspec.yaml index 08664996..107c5459 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 2.4.0 homepage: https://github.com/Polidea/FlutterBleLib environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=3.1.0 <4.0.0" # Flutter versions prior to 1.10 did not support the flutter.plugin.platforms map. flutter: ">=1.10.0 <2.0.0" @@ -16,7 +16,7 @@ dependencies: dev_dependencies: mockito: ^5.0.3 - build_runner: ^1.12.2 + build_runner: ^2.4.6 pedantic: ^1.11.0 flutter_test: