-
Notifications
You must be signed in to change notification settings - Fork 83
Migrate asset_handler_test
to null-safety
#1710
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
Conversation
asset_handler
testasset_handler_test
to null-safety
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.
Thanks Elliott! LGTM with a couple of questions an an optional ask.
await tabConnection.runtime.enable(); | ||
await tabConnection.debugger.enable(); | ||
final tab = await connection.getTab((t) => t.url == appUrl); | ||
if (tab != 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.
We should throw if tab is not found, the tests won't run properly in that case.
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.
Good point, done!
@@ -55,7 +55,7 @@ class DwdsVmClient { | |||
'$request'); | |||
return; | |||
} | |||
requestController.sink.add(jsonDecode(request) as Map<String, Object>); | |||
requestController.sink.add(Map<String, Object>.from(jsonDecode(request))); |
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.
I wonder if it is necessary to create a new object here (possible performance hit?)
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.
I'm not sure of another way - jsonDecode
returns dynamic
, so using as
to cast is throwing a type error (as
should only be used "if and only if you are sure that the object is of that type": https://dart.dev/guides/language/language-tour#type-test-operators)
@@ -53,7 +53,7 @@ void Function(WebSocketChannel, String) _createNewConnectionHandler( | |||
'Got value with unexpected type ${value.runtimeType} from web ' | |||
'socket, expected a List<int> or String.'); | |||
} | |||
final request = jsonDecode(value as String) as Map<String, Object>; | |||
final request = Map<String, Object>.from(jsonDecode(value)); |
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.
Is the new object necessary here as well?
No description provided.