Repository navigation
Override just the textScaleFactor - #12530
Conversation
There was a problem hiding this comment.
you could just require that there be a media query. Just assert(debugCheckHasMediaQuery(context)); at the top of the build method.
There was a problem hiding this comment.
OK. So what are the guidelines there: are material widgets expected to work outside of a MaterialApp, or not? Because the tests currently don't expect to provide a MediaQuery.
There was a problem hiding this comment.
Different widgets have different requirements. Many require a Material (not MaterialApp) ancestor, many require a MediaQuery ancestor, many require a Directionality or MaterialLocalizations ancestor. MaterialApp itself isn't required.
There was a problem hiding this comment.
Yeah, I was aware of the details, I just meant: In general, do we wish to write the widgets in the material/ directory so that they can be used without any of those ambient objects, or do we just expect that people will always use them in the context of a Material Design application.
It sounds like the answer is "We don't expect it to be a problem for people to add the ambient settings themselves if they want to use these widgets independently", which is a perfectly reasonable answer, I just wanted to know how to wire things up. :-)
There was a problem hiding this comment.
We definitely want it to be possible to use them without MaterialApp, but if people want to not use MaterialApp then yes, they should expect to have to do some of the work that MaterialApp does, which includes introducing a MediaQuery.
|
test? |
853c300 to
270ddad
Compare
|
Added a test to make sure I didn't override things I didn't mean to, but I kept the media query fallback as-is because that way it can be used outside of a MaterialApp (and in the existing tests). |
|
In that case you should make sure to test that it can be used without a MediaQuery. :-) But there's plenty of widgets that already require MediaQuery widgets. |
|
(I mean, just search for "debugCheckHasMediaQuery".) |
9bb79e8 to
0027dbf
Compare
|
OK, I've switched it to require a MediaQuery, and updated the tests so that they provide one. |
There was a problem hiding this comment.
if you say nullOk, you're going to get back null... which will promptly crash since you dereference it.
I think you want to remove nullOk.
There was a problem hiding this comment.
Duh. Yes, it definitely should be removed, although in point of fact it won't get the chance to return null, because of the assert above.
0027dbf to
0ed930a
Compare
Hixie pointed out that what I had before was resetting all of the MediaQuery values, not just textScaleFactor. This should fix that.