Skip to content

Override just the textScaleFactor - #12530

Merged
gspencergoog merged 1 commit into
flutter:masterfrom
gspencergoog:noscale_avatar
Oct 19, 2017
Merged

gspencergoog merged 1 commit into
flutter:masterfrom
gspencergoog:noscale_avatar

Conversation

@gspencergoog

Copy link
Copy Markdown
Contributor

Hixie pointed out that what I had before was resetting all of the MediaQuery values, not just textScaleFactor. This should fix that.

@Hixie Hixie Oct 13, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could just require that there be a media query. Just assert(debugCheckHasMediaQuery(context)); at the top of the build method.

@gspencergoog gspencergoog Oct 13, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. :-)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Hixie

Hixie commented Oct 13, 2017

Copy link
Copy Markdown
Contributor

test?

@gspencergoog

Copy link
Copy Markdown
Contributor Author

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).

@Hixie

Hixie commented Oct 13, 2017

Copy link
Copy Markdown
Contributor

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.

@Hixie

Hixie commented Oct 13, 2017

Copy link
Copy Markdown
Contributor

(I mean, just search for "debugCheckHasMediaQuery".)

@gspencergoog
gspencergoog force-pushed the noscale_avatar branch 2 times, most recently from 9bb79e8 to 0027dbf Compare October 13, 2017 19:53
@gspencergoog

Copy link
Copy Markdown
Contributor Author

OK, I've switched it to require a MediaQuery, and updated the tests so that they provide one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gspencergoog gspencergoog Oct 17, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Hixie

Hixie commented Oct 18, 2017

Copy link
Copy Markdown
Contributor

LGTM

@gspencergoog
gspencergoog merged commit 7e09649 into flutter:master Oct 19, 2017
@gspencergoog
gspencergoog deleted the noscale_avatar branch October 19, 2017 16:24
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants