Skip to content

Commit 12a0861

Browse files
authored
Release 2.2.9
Release 2.2.9
2 parents 6f05b2f + 832e18c commit 12a0861

File tree

7 files changed

+404
-39
lines changed

7 files changed

+404
-39
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2.9
2+
3+
* Fixed issue with incorrectly typed Stream
4+
15
## 2.2.8
26

37
* Formatted all sources according to dartfmt for consistency

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.polidea.flutter_ble_lib'
2-
version '2.2.8'
2+
version '2.2.9'
33

44
buildscript {
55
repositories {

ios/flutter_ble_lib.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
Pod::Spec.new do |s|
55
s.name = 'flutter_ble_lib'
6-
s.version = '2.2.8'
6+
s.version = '2.2.9'
77
s.summary = 'A new flutter plugin project.'
88
s.description = <<-DESC
99
A new flutter plugin project.

lib/src/bridge/device_connection_mixin.dart

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mixin DeviceConnectionMixin on FlutterBLE {
2525

2626
Stream<PeripheralConnectionState> observePeripheralConnectionState(
2727
String identifier, bool emitCurrentValue) {
28-
var controller = StreamController<String>(
28+
var controller = StreamController<PeripheralConnectionState>(
2929
onListen: () => _methodChannel.invokeMethod(
3030
MethodName.observeConnectionState,
3131
<String, dynamic>{
@@ -37,18 +37,15 @@ mixin DeviceConnectionMixin on FlutterBLE {
3737
),
3838
);
3939

40-
controller
41-
.addStream(_peripheralConnectionStateChanges)
42-
.then((value) => controller?.close());
43-
44-
return controller.stream
45-
.map((jsonString) =>
46-
ConnectionStateContainer.fromJson(jsonDecode(jsonString)))
47-
.where((connectionStateContainer) =>
48-
connectionStateContainer.peripheralIdentifier == identifier)
49-
.map((connectionStateContainer) =>
50-
connectionStateContainer.connectionState)
51-
.map((connectionStateString) {
40+
var sourceStream =
41+
_peripheralConnectionStateChanges
42+
.map((jsonString) =>
43+
ConnectionStateContainer.fromJson(jsonDecode(jsonString)))
44+
.where((connectionStateContainer) =>
45+
connectionStateContainer.peripheralIdentifier == identifier)
46+
.map((connectionStateContainer) =>
47+
connectionStateContainer.connectionState)
48+
.map((connectionStateString) {
5249
switch (connectionStateString.toLowerCase()) {
5350
case NativeConnectionState.connected:
5451
return PeripheralConnectionState.connected;
@@ -64,6 +61,15 @@ mixin DeviceConnectionMixin on FlutterBLE {
6461
);
6562
}
6663
});
64+
65+
controller
66+
.addStream(
67+
sourceStream,
68+
cancelOnError: true,
69+
)
70+
.then((value) => controller?.close());
71+
72+
return controller.stream;
6773
}
6874

6975
Future<bool> isPeripheralConnected(String peripheralIdentifier) async {

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_ble_lib
22
description: FlutterBle Library is a flutter library that supports BLE operations. It uses MultiPlatformBleAdapter as a native backend..
3-
version: 2.2.8
3+
version: 2.2.9
44
homepage: https://github.com/Polidea/FlutterBleLib
55

66
environment:

0 commit comments

Comments
 (0)