Skip to content

Commit cedaee1

Browse files
authored
Merge pull request #491 from Polidea/release/2.2.6
Release 2.2.6
2 parents e0b4415 + d23f2cd commit cedaee1

File tree

9 files changed

+44
-66
lines changed

9 files changed

+44
-66
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ res/values/strings_en.arb
1313
lib/generated/
1414
example/lib/generated/
1515
example/.flutter-plugins-dependencies
16-
.dart_tool/
16+
.dart_tool/
17+
example/ios/Podfile.lock

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ _android_job_template: &android_job_template
4747
_ios_job_template: &ios_job_template
4848
language: objective-c
4949
os: osx
50-
osx_image: xcode11
50+
osx_image: xcode11.6
5151
xcode_workspave: example/ios/Runner.xcworkspace
5252
xcode_scheme: Runner
5353
before_script:

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2.6
2+
3+
* Fixed scan quick failures not being reported to the listener (race condition in scanning_mixin.dart)
4+
15
## 2.2.5
26

37
* add missing handling of destroyClient call on iOS

android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.polidea.flutter_ble_lib'
2-
version '2.2.5'
2+
version '2.2.6'
33

44
buildscript {
55
repositories {

example/ios/Podfile.lock

-35
This file was deleted.

example/lib/devices_list/devices_list_view.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class DevicesListScreen extends StatefulWidget {
1919
class DeviceListScreenState extends State<DevicesListScreen> {
2020
DevicesBloc _devicesBloc;
2121
StreamSubscription _appStateSubscription;
22+
bool _shouldRunOnResume = true;
2223

2324
@override
2425
void didUpdateWidget(DevicesListScreen oldWidget) {
@@ -39,13 +40,13 @@ class DeviceListScreenState extends State<DevicesListScreen> {
3940
Fimber.d("navigate to details");
4041
_onPause();
4142
await Navigator.pushNamed(context, "/details");
42-
_shouldRunOnResume = true;
43+
setState(() {
44+
_shouldRunOnResume = true;
45+
});
4346
Fimber.d("back from details");
4447
});
4548
}
4649

47-
bool _shouldRunOnResume = true;
48-
4950
@override
5051
void didChangeDependencies() {
5152
super.didChangeDependencies();

ios/flutter_ble_lib.podspec

+1-1
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.5'
6+
s.version = '2.2.6'
77
s.summary = 'A new flutter plugin project.'
88
s.description = <<-DESC
99
A new flutter plugin project.

lib/src/bridge/scanning_mixin.dart

+30-23
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,49 @@
11
part of _internal;
22

33
mixin ScanningMixin on FlutterBLE {
4-
Stream<dynamic> _scanEvents;
4+
Stream<ScanResult> _scanEvents;
55

66
void _prepareScanEventsStream() {
7-
_scanEvents =
8-
const EventChannel(ChannelName.scanningEvents).receiveBroadcastStream();
7+
_scanEvents = const EventChannel(ChannelName.scanningEvents)
8+
.receiveBroadcastStream()
9+
.handleError(
10+
(errorJson) => throw BleError.fromJson(jsonDecode(errorJson.details)),
11+
test: (error) => error is PlatformException,
12+
)
13+
.map(
14+
(scanResultJson) =>
15+
ScanResult.fromJson(jsonDecode(scanResultJson), _manager),
16+
);
917
}
1018

1119
Stream<ScanResult> startDeviceScan(
1220
int scanMode,
1321
int callbackType,
1422
List<String> uuids,
1523
bool allowDuplicates,
16-
) async* {
17-
_methodChannel.invokeMethod(
18-
MethodName.startDeviceScan,
19-
<String, dynamic>{
20-
ArgumentName.scanMode: scanMode,
21-
ArgumentName.callbackType: callbackType,
22-
ArgumentName.uuids: uuids,
23-
ArgumentName.allowDuplicates: allowDuplicates,
24-
},
25-
);
26-
24+
) {
2725
if (_scanEvents == null) {
2826
_prepareScanEventsStream();
2927
}
3028

31-
yield* _scanEvents.handleError(
32-
(errorJson) {
33-
throw BleError.fromJson(jsonDecode(errorJson.details));
34-
},
35-
test: (error) => error is PlatformException,
36-
).map((scanResultJson) => ScanResult.fromJson(
37-
jsonDecode(scanResultJson),
38-
_manager,
39-
));
29+
StreamController<ScanResult> streamController = StreamController.broadcast(
30+
onListen: () => _methodChannel.invokeMethod(
31+
MethodName.startDeviceScan,
32+
<String, dynamic>{
33+
ArgumentName.scanMode: scanMode,
34+
ArgumentName.callbackType: callbackType,
35+
ArgumentName.uuids: uuids,
36+
ArgumentName.allowDuplicates: allowDuplicates,
37+
},
38+
),
39+
onCancel: () => stopDeviceScan(),
40+
);
41+
42+
streamController
43+
.addStream(_scanEvents, cancelOnError: true)
44+
.then((_) => streamController?.close());
45+
46+
return streamController.stream;
4047
}
4148

4249
Future<void> stopDeviceScan() async {

pubspec.yaml

+1-1
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.5
3+
version: 2.2.6
44
homepage: https://github.com/Polidea/FlutterBleLib
55

66
environment:

0 commit comments

Comments
 (0)