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
Show file tree
Hide file tree
Changes from 33 commits
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ lib/generated/
example/lib/generated/
example/.flutter-plugins-dependencies
.dart_tool/
example/ios/Podfile.lock
example/ios/Podfile.lock
.vscode/settings.json
org.eclipse.buildship.core.prefs
.project
.classpath
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ _android_job_template: &android_job_template
_ios_job_template: &ios_job_template
language: objective-c
os: osx
osx_image: xcode11.6
osx_image: xcode12.2
xcode_workspave: example/ios/Runner.xcworkspace
xcode_scheme: Runner
before_script:
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ Add [Privacy - Bluetooth Always Usage Description](https://developer.apple.com/d
...
```

#### Background mode

To support background capabilities add [The `bluetooth-central` Background Execution Mode](https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW6) key to `[project]/ios/Runner/Info.plist` file.

```xml
...
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>
...
```

## Usage

The library is organised around a few base entities, which are:
Expand Down
11 changes: 10 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
include: package:pedantic/analysis_options.yaml
include: package:pedantic/analysis_options.yaml

analyzer:
exclude: [test/**]

linter:
rules:
prefer_single_quotes: false
omit_local_variable_types: false
unawaited_futures: false
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ public void onEvent(Integer restoreStateIdentifier) {
}

private void destroyClient(Result result) {
bleAdapter.destroyClient();
if (bleAdapter != null) {
bleAdapter.destroyClient();
}
scanningStreamHandler.onComplete();
connectionStateStreamHandler.onComplete();
bleAdapter = null;
Expand Down Expand Up @@ -167,13 +169,17 @@ public void onError(BleError error) {
}

private void stopDeviceScan(Result result) {
bleAdapter.stopDeviceScan();
if (bleAdapter != null) {
bleAdapter.stopDeviceScan();
}
scanningStreamHandler.onComplete();
result.success(null);
}

private void cancelTransaction(MethodCall call, Result result) {
bleAdapter.cancelTransaction(call.<String>argument(ArgumentKey.TRANSACTION_ID));
if (bleAdapter != null) {
bleAdapter.cancelTransaction(call.<String>argument(ArgumentKey.TRANSACTION_ID));
}
result.success(null);
}
}
2 changes: 0 additions & 2 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,11 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/Flutter.framework",
mikolak marked this conversation as resolved.
Show resolved Hide resolved
"${BUILT_PRODUCTS_DIR}/MultiplatformBleAdapter/MultiplatformBleAdapter.framework",
"${BUILT_PRODUCTS_DIR}/flutter_ble_lib/flutter_ble_lib.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MultiplatformBleAdapter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_ble_lib.framework",
);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions example/lib/device_details/device_detail_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class DeviceDetailsView extends StatefulWidget {
}

class DeviceDetailsViewState extends State<DeviceDetailsView> {
DeviceDetailsBloc _deviceDetailsBloc;
StreamSubscription _appStateSubscription;
DeviceDetailsBloc? _deviceDetailsBloc;
StreamSubscription? _appStateSubscription;

bool _shouldRunOnResume = true;

Expand All @@ -33,9 +33,9 @@ class DeviceDetailsViewState extends State<DeviceDetailsView> {

void _onResume() {
Fimber.d("onResume");
_deviceDetailsBloc.init();
_deviceDetailsBloc?.init();
_appStateSubscription =
_deviceDetailsBloc.disconnectedDevice.listen((bleDevice) async {
_deviceDetailsBloc?.disconnectedDevice.listen((bleDevice) async {
Fimber.d("navigate to details");
_onPause();
Navigator.pop(context);
Expand All @@ -46,8 +46,8 @@ class DeviceDetailsViewState extends State<DeviceDetailsView> {

void _onPause() {
Fimber.d("onPause");
_appStateSubscription.cancel();
_deviceDetailsBloc.dispose();
_appStateSubscription?.cancel();
_deviceDetailsBloc?.dispose();
}

@override
Expand All @@ -59,9 +59,13 @@ class DeviceDetailsViewState extends State<DeviceDetailsView> {

@override
Widget build(BuildContext context) {
final deviceDetailsBloc = _deviceDetailsBloc;
return WillPopScope(
onWillPop: () {
return _deviceDetailsBloc.disconnect().then((_) {
if (deviceDetailsBloc == null) {
return Future<bool>.value(true);
}
return deviceDetailsBloc.disconnect().then((_) {
return false;
});
},
Expand All @@ -86,8 +90,10 @@ class DeviceDetailsViewState extends State<DeviceDetailsView> {
),
body: TabBarView(
children: <Widget>[
AutoTestView(_deviceDetailsBloc),
ManualTestView(_deviceDetailsBloc),
if (deviceDetailsBloc != null)
AutoTestView(deviceDetailsBloc),
if (deviceDetailsBloc != null)
ManualTestView(deviceDetailsBloc),
],
)),
),
Expand Down
Loading