Skip to content

Update Gallery usage of Scaffold.of #6639

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

Merged
merged 1 commit into from
Nov 4, 2016

Conversation

jason-simmons
Copy link
Member

No description provided.

@abarth
Copy link
Contributor

abarth commented Nov 2, 2016

LGTM

@abarth
Copy link
Contributor

abarth commented Nov 2, 2016

/cc @Hixie

@Hixie
Copy link
Contributor

Hixie commented Nov 2, 2016

@HansMuller are you expecting this to return null?

Ideally we'd have a test for this too...

@HansMuller
Copy link
Contributor

The existing Scaffold.of(context)?.appBarAnimation should not have included the '?.'.

The Scaffold.of() call is within a Builder widget that only exists so that the Scaffold.of() call will succeed.

@Hixie
Copy link
Contributor

Hixie commented Nov 2, 2016

So it should not be returning null? It apparently is...

@HansMuller
Copy link
Contributor

The problem appears to be the Scaffold's key:
https://github.com/flutter/flutter/blob/master/examples/flutter_gallery/lib/gallery/home.dart#L102

I don't think there's any need for _homeKey and removing it fixes the problem.

@jason-simmons
Copy link
Member Author

I'm still seeing Scaffold.of() returning null after removing the _homeKey

@HansMuller
Copy link
Contributor

Yes, sorry about the misdirection. Although the problem seemed to have gone away after removing _homeKey (which I still don't think is needed), trying the remedy again fails for me too.

@jason-simmons
Copy link
Member Author

Scaffold.of() seems to be returning null due to some sort of race involving the hero animation subsystem.

If the Builder within Gallery's AppBar is invoked while the animation is still in progress, then the AppBar widgets will be descendants of the HeroQuestState transition widgets and will not have a Scaffold ancestor.

@Hixie

@abarth
Copy link
Contributor

abarth commented Nov 2, 2016

Oh, that makes sense. During the page transition, the AppBar is a hero that persists during the transition. When it is transitioning, it isn't a child of the scaffold.

@jason-simmons
Copy link
Member Author

Changed this to use a GlobalKey to locate the scaffold

PTAL

@HansMuller
Copy link
Contributor

LGTM!

@Hixie
Copy link
Contributor

Hixie commented Nov 4, 2016

Ideally this would have a test -- in fact I'm surprised the smoketest didn't catch this.

@jason-simmons jason-simmons merged commit 46b6077 into flutter:master Nov 4, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 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.

4 participants