Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullsafety #586

Merged
merged 35 commits into from
Apr 13, 2021
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a64021c
Work in progress
okocsis Mar 26, 2021
cd829b2
lib/** nullability compliant;
okocsis Mar 29, 2021
44cf93f
Example:: updated to nullsafe-ready dependencies
okocsis Mar 29, 2021
7cff4d4
Example:: nullsafety + refactor WIP
okocsis Mar 30, 2021
991473f
Example:: nullsafe ready
okocsis Mar 30, 2021
fdac568
Example/test:: nullsafe ready
okocsis Mar 30, 2021
5ba2668
test:: using new mocking mechanism
okocsis Mar 31, 2021
44cb104
Java: added some null checks to make the calls to stop and destroy re…
okocsis Apr 1, 2021
67f1b5a
Example:: additional cleanup and refactor
okocsis Apr 1, 2021
a3277e7
TestFix:: the injected manager instance is not part of the Characteri…
okocsis Apr 5, 2021
ae7d4dc
ble_error seem to have rather nullable fields
okocsis Apr 5, 2021
8b1175b
TestFix: little refactor on characteristic_mixin regarding clearity a…
okocsis Apr 5, 2021
b58f8a0
TestFix:: lib_core_test:: tests now passing
okocsis Apr 5, 2021
682260b
Example:: removed comment-disabled code
okocsis Apr 6, 2021
2292ffc
Test:: all tests Passing now! 🎉
okocsis Apr 6, 2021
ca0cd3c
Enhanced BleError nullability, so that reason always has a default va…
okocsis Apr 6, 2021
46aa6bf
Travis fix
okocsis Apr 7, 2021
50cb727
disabled analysis for tests
okocsis Apr 7, 2021
2b7979b
Travis:: still fixing ios build
okocsis Apr 7, 2021
72f30f2
vscode:: stopped tracking settings file
okocsis Apr 7, 2021
b486789
travis:: removed my additions to ios example script
okocsis Apr 7, 2021
5f5c576
Characteristic:: Service field is now final
okocsis Apr 7, 2021
5f68124
gitignored andoid related staff
okocsis Apr 8, 2021
1da3feb
Add bluetooth-central key to README.md (#562)
wcoder Apr 8, 2021
56756e1
Travis: updated xcode version to 12.2
okocsis Apr 8, 2021
9d148b6
Merge commit '1da3feb70ed4f853145049fe3c5c4ec16080b287' into nullsafety
okocsis Apr 8, 2021
9bd3e05
BleError:: default reason text added
okocsis Apr 8, 2021
5442bfa
ScanResult::
okocsis Apr 8, 2021
fc130ba
CharacteristicsMixin::
okocsis Apr 8, 2021
0d040db
Test:: removed dummy print
okocsis Apr 8, 2021
b47cce9
ScanningMixin:: _prepareScanEventsStream() renamed to just _scanEvents
okocsis Apr 11, 2021
c9c8d60
ScanningMixin:: small refinement on naming stuff
okocsis Apr 12, 2021
86dafd6
Characteristic:: refactor on Futures to always complete with somethin…
okocsis Apr 12, 2021
a46482d
Revert "Characteristic:: refactor on Futures to always complete with …
okocsis Apr 13, 2021
d2fc7de
Merge commit 'aaa2009274a0b6c48a0eeae7565143f87b89ee2c' into nullsafety
okocsis Apr 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions lib/src/bridge/scanning_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
part of _internal;

mixin ScanningMixin on FlutterBLE {
Stream<ScanResult>? _scanEvents;

Stream<ScanResult> _prepareScanEventsStream() {
return const EventChannel(ChannelName.scanningEvents)
.receiveBroadcastStream()
.handleError(
(errorJson) => throw BleError.fromJson(jsonDecode(errorJson.details)),
Stream<ScanResult>? __scanEvents;
mikolak marked this conversation as resolved.
Show resolved Hide resolved
Stream<ScanResult> get _scanEvents {
var scanEvents = __scanEvents;
if (scanEvents == null) {
scanEvents =
const EventChannel(
ChannelName.scanningEvents
).receiveBroadcastStream(
).handleError(
mikolak marked this conversation as resolved.
Show resolved Hide resolved
(errorJson) => throw BleError.fromJson(
jsonDecode(errorJson.details)
),
test: (error) => error is PlatformException,
)
.map(
).map(
(scanResultJson) =>
ScanResult.fromJson(jsonDecode(scanResultJson), _manager),
);
__scanEvents = scanEvents;
}
return scanEvents;
}
void _resetScanEvents() {
__scanEvents = null;
}

Stream<ScanResult> startDeviceScan(
Expand All @@ -22,12 +32,6 @@ mixin ScanningMixin on FlutterBLE {
List<String> uuids,
bool allowDuplicates,
) {
var scanEvents = _scanEvents;
if (scanEvents == null) {
scanEvents = _prepareScanEventsStream();
_scanEvents = scanEvents;
}

final streamController = StreamController<ScanResult>.broadcast(
onListen: () => _methodChannel.invokeMethod(
MethodName.startDeviceScan,
Expand All @@ -42,15 +46,15 @@ mixin ScanningMixin on FlutterBLE {
);

streamController
.addStream(scanEvents, cancelOnError: true)
.addStream(_scanEvents, cancelOnError: true)
.then((_) => streamController.close());

return streamController.stream;
}

Future<void> stopDeviceScan() async {
await _methodChannel.invokeMethod(MethodName.stopDeviceScan);
_scanEvents = null;
_resetScanEvents();
return;
}
}