Factor out unnecessary asserts#182042
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors several setters in CupertinoSwitch and MaterialSwitch to leverage Dart's null safety. By changing the parameter types from nullable to non-nullable, the unnecessary assert(value != null) checks are removed, and null-correctness is now enforced at compile time instead of runtime. The changes are correct and improve code quality and clarity.
dkwingsmt
left a comment
There was a problem hiding this comment.
LGTM. Thank you for the cleanup!
|
autosubmit label was removed for flutter/flutter/182042, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR. |
5525711 to
e7008f8
Compare
|
autosubmit label was removed for flutter/flutter/182042, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
Google test failure looks like an infra flake, rerunning... |
|
autosubmit label was removed for flutter/flutter/182042, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
The conversation in flutter#181703 got me thinking about whether there were any `assert(value != null)` statements in our codebase that were written prior to Dart's null safety era and could be factored out. It turns out that there are! This PR updates a few setters so that incorrect `null` assignments are caught by static analysis instead of potentially going unnoticed until runtime. Co-authored-by: Victor Sanni <[email protected]>
The conversation in flutter#181703 got me thinking about whether there were any `assert(value != null)` statements in our codebase that were written prior to Dart's null safety era and could be factored out. It turns out that there are! This PR updates a few setters so that incorrect `null` assignments are caught by static analysis instead of potentially going unnoticed until runtime. Co-authored-by: Victor Sanni <[email protected]>
The conversation in #181703 got me thinking about whether there were any
assert(value != null)statements in our codebase that were written prior to Dart's null safety era and could be factored out.It turns out that there are!
This PR updates a few setters so that incorrect
nullassignments are caught by static analysis instead of potentially going unnoticed until runtime.