-
Notifications
You must be signed in to change notification settings - Fork 199
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
Update json scan_result parsing #584
base: develop
Are you sure you want to change the base?
Conversation
lib/scan_result.dart
Outdated
@@ -32,7 +32,7 @@ class ScanResult { | |||
: peripheral = Peripheral.fromJson(json, manager), | |||
rssi = json[_ScanResultMetadata.rssi], | |||
isConnectable = json[_ScanResultMetadata.isConnectable], | |||
overflowServiceUuids = json[_ScanResultMetadata.overflowServiceUuids], | |||
overflowServiceUuids = _mapToListOfStringsOrNull(json[_ScanResultMetadata.overflowServiceUuids]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
lib/scan_result.dart
Outdated
} | ||
|
||
List<String> _mapToListOfStringsOrNull(List<dynamic> values) => (values ?? []).cast(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the change of behaviour? Most of those properties might be an array or null on native and that's what this function did - either map dynamics from the list to strings or preserve the null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be a better idea to, with recent nullsafety changes in mind, return an empty list instead of null?
Otherwise it would be no problem to just continue with the values?.cast()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null is a more definitive indication that there are no such values retrieved. I like the idea of eliminating null, but I'd have to examine the rest of this file and analyze if this could be breaking or not. I'll try to do that tomorrow.
iOS has overflow uuids, the list containing these items is a
List<dynamic>
which couldn't be cast to aList<String>