Skip to content

Conversation

@gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Jul 19, 2017

This fixes a problem with Navigator.pop where the routes were created with MaterialPageRoute<Null>, which breaks any call to Navigator.pop with an argument other than Null.

gspencergoog and others added 28 commits June 13, 2017 10:57
Pulling from main fork.
Pulling to make workspace up to date wrt master.
Bringing master up to date wrt workspace
Merging changes from flutter/flutter
Updating my flutter fork to master.
Pulling from flutter/flutter
final String name;
final BuildContext context;

const PopWidget(this.context, this.name, this.value);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: constructor always comes first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks.

final String name;
final BuildContext context;

const PopWidget(this.context, this.name, this.value);
Copy link
Contributor

Choose a reason for hiding this comment

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

passing a context to a widget is pretty crazy. Maybe instead of a PopWidget, use a Builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I thought it was pretty crazy too, I was just looking for a way to delay the pop until after building was done. Thanks for the suggestion: it's much simpler now.

<excludeFolder url="file://$MODULE_DIR$/packages" />
<excludeFolder url="file://$MODULE_DIR$/test/calculator/packages" />
<excludeFolder url="file://$MODULE_DIR$/test/packages" />
<excludeFolder url="file://$MODULE_DIR$/tool/packages" />
Copy link
Contributor

Choose a reason for hiding this comment

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

did you mean to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Urg. No.

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<module type="FLUTTER_MODULE_TYPE" version="4">
Copy link
Contributor

Choose a reason for hiding this comment

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

or this?

@Hixie
Copy link
Contributor

Hixie commented Jul 21, 2017

It's a pity that there's no way to dynamically fill the type there, but:
LGTM

@gspencergoog
Copy link
Contributor Author

Well, but where would it get the type from?: we don't know the type until pop is called, so it kind of has to be dynamic.

Anyhow, thanks for the review!

@Hixie
Copy link
Contributor

Hixie commented Jul 21, 2017

The route knows the type when it's created. A language with good RTTI could let us do it. But yeah, not in Dart. :-)

@gspencergoog
Copy link
Contributor Author

gspencergoog commented Jul 21, 2017

But for named routes, there is no type that the user specifies, since they just supply a builder, and we create the MaterialPageRoute for them. The pop is what determines the type for named routes. For other routes, it'll fail when calling didPop if the result is the wrong type.

Hey, what's the deal with Travis? Seems like most of my runs for this PR have been failing through no fault of my code...

@Hixie
Copy link
Contributor

Hixie commented Jul 21, 2017

The pop doesn't determine the type. The type is there to ensure the pop is providing the right type. The type is decided by the person who defined the route. For example, a page where you edit a contact might be defined as returning a Contact class. It would be an error if any of the ways to pop that page returned, say, an integer or a string.

Not sure what's up with Travis.

@Hixie
Copy link
Contributor

Hixie commented Jul 21, 2017

Did you mean to add the arguments feature?

@gspencergoog
Copy link
Contributor Author

Dammmit. No. I was trying to bring my branch up to current flutter/master. I went through my local master, which must have had that in it still. From now on, I'm nuking my local repos before each change. :-)

Removed.

@gspencergoog
Copy link
Contributor Author

gspencergoog commented Jul 21, 2017

Yes, the Route<T>.didPop validates the type, but in the case of the routes: map in the app, the first chance the user has to supply a type is in the pop, since the app is creating the MaterialPageRoute for them.

@Hixie
Copy link
Contributor

Hixie commented Jul 21, 2017

Yeah. Like I said, it's a pity. :-) Not much I can think to do about it.

Anyway, all is green, so I've landed your patch. Thanks!

@Hixie Hixie merged commit e4860ef into flutter:master Jul 21, 2017
@gspencergoog gspencergoog deleted the fix_pop branch September 29, 2017 23:21
@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