Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
null check getAll
  • Loading branch information
bparrishMines committed Jan 27, 2021
commit 0382c6f734c4037c042e925d5110f1f66857b6f4
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class MethodChannelSharedPreferencesStore

@override
Future<Map<String, Object>> getAll() async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we certain that no platform implementation ever returns null here? It might be a good idea to bullet-proof this with a null check on the results, returning an empty map if the channel's result was null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return await _kChannel.invokeMapMethod<String, Object>('getAll')
as Map<String, Object>;
final Map<String, Object>? preferences =
await _kChannel.invokeMapMethod<String, Object>('getAll');

if (preferences == null) return <String, Object>{};
return preferences;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void main() {
}
final RegExp setterRegExp = RegExp(r'set(.*)');
final Match? match = setterRegExp.matchAsPrefix(methodCall.method);
if (match != null && match.groupCount == 1) {
final String valueType = match.group(1)!;
if (match?.groupCount == 1) {
final String valueType = match!.group(1)!;
final String key = methodCall.arguments['key'];
final Object value = methodCall.arguments['value'];
return await testData.setValue(valueType, key, value);
Expand Down