Skip to content

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Jun 25, 2020

Description

Introduce router widget and widgets app api, I will include the stock app rewrite in a separate pr once we agree on the api details

stock app rewrite draft chunhtai#2

Related Issues

#45938

Tests

I added the following tests:

See files

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

@fluttergithubbot fluttergithubbot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. work in progress; do not review labels Jun 25, 2020
@chunhtai chunhtai force-pushed the nav-refactor-router-alone branch from ea1e776 to df72c94 Compare June 30, 2020 00:23
@chunhtai chunhtai changed the title [WIP]Implement Router widget and widgets app api Implement Router widget and widgets app api Jun 30, 2020
@chunhtai chunhtai removed f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. work in progress; do not review labels Jun 30, 2020
@fluttergithubbot fluttergithubbot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. work in progress; do not review labels Jun 30, 2020
@chunhtai chunhtai removed f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jun 30, 2020
@chunhtai chunhtai force-pushed the nav-refactor-router-alone branch from 43dca20 to 25630c6 Compare July 8, 2020 20:12
@chunhtai chunhtai marked this pull request as ready for review July 8, 2020 22:55
@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jul 8, 2020
@chunhtai chunhtai requested review from Hixie and goderbauer July 8, 2020 22:55
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mdebbar @goderbauer as we discussed before, we want to have an api to force create a browser history entry or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Having a boolean as an argument after the callback makes it hard to read. I suggest either splitting into two methods or move the boolean argument before the callback.

@chunhtai
Copy link
Contributor Author

a friendly bump

@Hixie
Copy link
Contributor

Hixie commented Jul 14, 2020

FWIW, it's hard for me to evaluate the API really without the stocks app migration as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "if we use"

@Hixie
Copy link
Contributor

Hixie commented Aug 6, 2020

We should convert it to use the standard codec, if we can. I just don't want to be adding any more places where we're converting data to JSON, it's highly inefficient.

@chunhtai
Copy link
Contributor Author

chunhtai commented Aug 6, 2020

@Hixie I opened a separate issue about converting navigation channel #63121
I would not do it as part of this pr because it may involve multiple stage migration and this pr is already massive

in the meanwhile, I addressed all other comments. This pr is ready for another look @goderbauer and @Hixie

@chunhtai chunhtai force-pushed the nav-refactor-router-alone branch 2 times, most recently from 41afc9e to 8c54425 Compare August 6, 2020 21:48
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@goderbauer
we have to do this check because method channel invoke method will throw if there is no corresponding listener on the engine side.

Copy link
Member

Choose a reason for hiding this comment

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

Should the navigator channel be an OptionalMethodChannel to avoid that problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have to reuse the old method until the engine side method is in place otherwise it will throw an exception.

Copy link
Member

Choose a reason for hiding this comment

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

Instead of duplication the code, forward the call to routeUpdated?

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

Just some minor comments.

Copy link
Member

Choose a reason for hiding this comment

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

... are stored ...

Copy link
Member

Choose a reason for hiding this comment

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

Should the navigator channel be an OptionalMethodChannel to avoid that problem?

Copy link
Member

Choose a reason for hiding this comment

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

nit: space between if and (.

Copy link
Member

Choose a reason for hiding this comment

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

same blow.

Comment on lines 45 to 47
Copy link
Member

Choose a reason for hiding this comment

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

Just remove the else? Same above.

Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be typed "Object". Maybe take everything that's in the map as named arguments?

Copy link
Member

Choose a reason for hiding this comment

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

Instead of duplication the code, forward the call to routeUpdated?

Copy link
Member

Choose a reason for hiding this comment

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

Make these named arguments?

@goderbauer
Copy link
Member

Looks like there are some doc errors.

The StandartMessageCodec/JSON question aside, this LGTM.

@chunhtai chunhtai force-pushed the nav-refactor-router-alone branch from b642cf6 to 9a2d2fd Compare August 7, 2020 20:49
@chunhtai chunhtai force-pushed the nav-refactor-router-alone branch from 9a2d2fd to 0b113e9 Compare August 7, 2020 21:17
@@ -1,41 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just realized we are not exposing this api in the package level, we should be good to remove this without a breaking change

@chunhtai
Copy link
Contributor Author

chunhtai commented Aug 7, 2020

addressed all comments, and also updated the stock app rewrite pr https://github.com/chunhtai/flutter/pull/2/files

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

Widget routing;
if (_usesRouter) {
assert(_effectiveRouteInformationProvider != null);
routing = Router<dynamic>(
Copy link
Contributor

Choose a reason for hiding this comment

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

i missed that we were creating this with dynamic as the type here. That seems to defeat the purpose of having a T type argument on Router...

Not sure what the right answer is, but we should probably find a better solution than defining the API with T then ignoring it.

(I noticed this because we're changing dynamic to Object as part of the NNBD transition.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was struggling hard on this one too, you can not set T for a single constructor, and it is weird to define on the class level because non router constructor does not care. we could separate out router constructor to a class or method on its own, but that seems to add a whole lot of complexity to the code. For now, it will let you initialize with different type of route information parser and router delegate, but it will throw on build

mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants