-
Notifications
You must be signed in to change notification settings - Fork 27.5k
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
Remove nullOk
in MediaQuery.of
#68736
Conversation
nullOk
in MediaQuery.of
a3f89ee
to
08827b6
Compare
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.
Changes LGTM. Since this is failing google3 I would argue that this is a breaking change, though, and we should probably publish a quick migration guide.
I agree, I'll work on the guide. |
@bwilkerson This would be another great use case for a flutter fix that automatically migrates user code. |
Here's the design doc for the migration. Writing the migration guide itself next. |
9745730
to
46010dd
Compare
OK, I just removed the |
It's a pity we lose the analyzer warning that way. |
nullOk
in MediaQuery.of
nullOk
in MediaQuery.of
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.
LGTM
cc477aa
to
938508b
Compare
@Hixie Well, we lose the analyzer warning, but gain a compiler error. I agree, is a pity that there's no way to say "Fail to compile, but give a custom message like a deprecation" for when someone uses a removed parameter. Hopefully the docs at the site are clear enough that they'll understand what to do when they get the compiler error. |
938508b
to
f5c40b1
Compare
Might be worth following up with @leafpetersen to see if we can change Dart in some way in the future to make this kind of thing better. |
OK, I submitted dart-lang/sdk#43942 as a feature request. |
f5c40b1
to
c655248
Compare
This pull request is not suitable for automatic merging in its current state.
|
This pull request is not suitable for automatic merging in its current state.
|
This constructor has been replaced by a new MediaQuery.maybeOf() constructor. flutter/flutter#68736
Description
Adds
MediaQuery.maybeOf
to replace callingMediaQuery.of(context, nullOk: true)
, and removes thenullOk
parameter. Also changesMediaQuery.of
to return a non-nullable value, and removes many instances of the!
operator, reducing the possible places where a null dereference could occur.Related Issues
Tests
maybeOf
works as expected, updated test output for media_query_test.dart and others.Breaking Change