Update json scan_result parsing#584
Open
sjoerd0301 wants to merge 3 commits intodotintent:developfrom
Open
Conversation
mikolak
reviewed
Apr 7, 2021
lib/scan_result.dart
Outdated
| rssi = json[_ScanResultMetadata.rssi], | ||
| isConnectable = json[_ScanResultMetadata.isConnectable], | ||
| overflowServiceUuids = json[_ScanResultMetadata.overflowServiceUuids], | ||
| overflowServiceUuids = _mapToListOfStringsOrNull(json[_ScanResultMetadata.overflowServiceUuids]), |
lib/scan_result.dart
Outdated
| values?.cast(); | ||
| } | ||
|
|
||
| List<String> _mapToListOfStringsOrNull(List<dynamic> values) => (values ?? []).cast(); No newline at end of file |
Collaborator
There was a problem hiding this comment.
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.
Author
There was a problem hiding this comment.
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()
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
iOS has overflow uuids, the list containing these items is a
List<dynamic>which couldn't be cast to aList<String>