Repository navigation
Remove nullOk in MediaQuery.of - #68736
Conversation
nullOk in MediaQuery.of
a3f89ee to
08827b6
Compare
goderbauer
left a comment
There was a problem hiding this comment.
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.ofnullOk in MediaQuery.of
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.maybeOfto replace callingMediaQuery.of(context, nullOk: true), and removes thenullOkparameter. Also changesMediaQuery.ofto 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
maybeOfworks as expected, updated test output for media_query_test.dart and others.Breaking Change