Skip to content

Push nested routes - #4763

Closed
devoncarew wants to merge 4 commits into
flutter:masterfrom
devoncarew:push_nested_routes
Closed

devoncarew wants to merge 4 commits into
flutter:masterfrom
devoncarew:push_nested_routes

Conversation

@devoncarew

@devoncarew devoncarew commented Jun 27, 2016 •

Copy link
Copy Markdown
Contributor

Some work towards #4702.

When I run this against flutter_gallery with the route /buttons, I get the following exception (on pushing /buttons, after pushing /):

I/flutter : ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter : The following assertion was thrown building Title("Flutter Gallery"; color: Color(0xff009688)):
I/flutter : Unable to find the BuildContext for the Navigator's overlay.
I/flutter : Did you remember to pass the settings object to the route's constructor in your onGenerateRoute
I/flutter : callback?
I/flutter : When the exception was thrown, this was the stack:
I/flutter : #0      ModalRoute.didPush.<anonymous closure> (package:flutter/src/widgets/routes.dart:531)
I/flutter : #1      _AssertionError._checkAssertion (dart:core-patch/errors_patch.dart:31)
I/flutter : #2      ModalRoute.didPush (package:flutter/src/widgets/routes.dart:529)
I/flutter : #3      NavigatorState._push.<anonymous closure> (package:flutter/src/widgets/navigator.dart:401)
I/flutter : #4      State.setState (package:flutter/src/widgets/framework.dart:781)
I/flutter : #5      NavigatorState._push (package:flutter/src/widgets/navigator.dart:396)
I/flutter : #6      NavigatorState.initState (package:flutter/src/widgets/navigator.dart:332)

@Hixie, does anything jump out at you here? Something simple? Perhaps something I'm doing that's not expected by the framework?

@Hixie

Hixie commented Jun 27, 2016

Copy link
Copy Markdown
Contributor

@abarth this is hitting your recent work on moving focus. The problem is that we are pushing multiple routes on startup, and so only one is marked as "initial", so we're going down the non-initial codepath, which is expecting to already have been built at least once.

name: route,
isInitialRoute: isFirst
)));
isFirst = false;

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.

What happens if you pass true for isInitialRoute for all of these? You don't want them to animate in either, which means you want them to all be "initial". (We should probably rename isInitialRoute to something that makes sense in this context).

@devoncarew

Copy link
Copy Markdown
Contributor Author

It gets a bit further along - the app starts up and displays the main screen, but I get an exception later on - perhaps when responding to the /buttons route push?

I/flutter : ══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter : The following NoSuchMethodError was thrown during a scheduler callback:
I/flutter : The null object does not have a method 'visitChildElements'.
I/flutter : NoSuchMethodError: method not found: 'visitChildElements'
I/flutter : Receiver: null
I/flutter : Arguments: [Closure: (Element) => void]
I/flutter : When the exception was thrown, this was the stack:
I/flutter : #0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
I/flutter : #1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
I/flutter : #2      Hero.of (package:flutter/src/widgets/heroes.dart:131)
I/flutter : #3      HeroController._updateQuest (package:flutter/src/widgets/heroes.dart:496)
I/flutter : #4      BindingBase&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:476)
I/flutter : #5      BindingBase&SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:444)
I/flutter : #6      _beginFrame (file:///b/build/slave/Linux_Engine/build/src/out/android_debug_x64/gen/sky/bindings/dart_ui/hooks.dart:48)
I/flutter : ════════════════════════════════════════════════════════════════════════════════════════════════════

@devoncarew

devoncarew commented Jun 27, 2016 •

Copy link
Copy Markdown
Contributor Author

If I insert a delay before pushing routes (apart from the first segment), I don't see the exception. Something like:

Timer.run(() {
  _push(config.onGenerateRoute(new RouteSettings(
    name: routeFragment,
    isInitialRoute: true
  )));        
});

@abarth

abarth commented Jun 27, 2016

Copy link
Copy Markdown
Contributor

I'm not sure we want to use asynchrony here. Can you explain a bit more about what you're trying to achieve? You'd like to start the app up with some history already in place?

@abarth

abarth commented Jun 27, 2016

Copy link
Copy Markdown
Contributor

I might have fixed the hero quest issue in #4769

@devoncarew

Copy link
Copy Markdown
Contributor Author

I'm not sure we want to use asynchrony here. Can you explain a bit more about what you're trying to achieve? You'd like to start the app up with some history already in place?

Yup, if the initial route is /foo/bar, I'd like the history to be / and /foo, and the current page to be /foo/bar. When I tried pushing the routes on all at once I saw the exception above. I also saw a separate exception when I tried populating the _history list.

I don't think the asynchrony is a good solution here, more me experimenting and trying to get things to work. I'll try a simpler solution w/ your hero fix.

@devoncarew devoncarew closed this Jun 27, 2016
aam added a commit to aam/flutter that referenced this pull request Mar 12, 2018
Changes since last roll:
```
b6df7a6 Roll dart to 290c576264faa096a0b3206c71b2435309d9f904. (flutter#4771)
a6764db Add sources for Fuchsia target. (flutter#4763)
2d59006 [fuchsia] Remove unused header file. (flutter#4769)
9717063 Revert "Roll dart to c080951d45e79cd25df98036c4be835b284a269c. (flutter#4767)" (flutter#4768)
9a98143 Roll dart to c080951d45e79cd25df98036c4be835b284a269c. (flutter#4767)
e74e8b3 [async] Update includes of async headers to new path (flutter#4760)
e2c4b27 Use Dart 2 camel case constants in the engine Dart libraries (flutter#4766)
9c1e484 Updates for Fuchsia roll. (flutter#4765)
14c940e Switch from fxl::Mutex to std::mutex (flutter#4764)
debf82c Roll Garnet (flutter#4759)
5bffdef Use weak pointers to the accesibility bridge from objects vended to the UIKit accessibility framework. (flutter#4761)
```
aam added a commit that referenced this pull request Mar 12, 2018
* Roll engine to b6df7a6.

Changes since last roll:
```
b6df7a6 Roll dart to 290c576264faa096a0b3206c71b2435309d9f904. (#4771)
a6764db Add sources for Fuchsia target. (#4763)
2d59006 [fuchsia] Remove unused header file. (#4769)
9717063 Revert "Roll dart to c080951d45e79cd25df98036c4be835b284a269c. (#4767)" (#4768)
9a98143 Roll dart to c080951d45e79cd25df98036c4be835b284a269c. (#4767)
e74e8b3 [async] Update includes of async headers to new path (#4760)
e2c4b27 Use Dart 2 camel case constants in the engine Dart libraries (#4766)
9c1e484 Updates for Fuchsia roll. (#4765)
14c940e Switch from fxl::Mutex to std::mutex (#4764)
debf82c Roll Garnet (#4759)
5bffdef Use weak pointers to the accesibility bridge from objects vended to the UIKit accessibility framework. (#4761)
```
cdotstout pushed a commit to cdotstout/flutter that referenced this pull request Apr 3, 2018
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
* Roll engine to b6df7a6.

Changes since last roll:
```
b6df7a6 Roll dart to 290c576264faa096a0b3206c71b2435309d9f904. (flutter#4771)
a6764db Add sources for Fuchsia target. (flutter#4763)
2d59006 [fuchsia] Remove unused header file. (flutter#4769)
9717063 Revert "Roll dart to c080951d45e79cd25df98036c4be835b284a269c. (flutter#4767)" (flutter#4768)
9a98143 Roll dart to c080951d45e79cd25df98036c4be835b284a269c. (flutter#4767)
e74e8b3 [async] Update includes of async headers to new path (flutter#4760)
e2c4b27 Use Dart 2 camel case constants in the engine Dart libraries (flutter#4766)
9c1e484 Updates for Fuchsia roll. (flutter#4765)
14c940e Switch from fxl::Mutex to std::mutex (flutter#4764)
debf82c Roll Garnet (flutter#4759)
5bffdef Use weak pointers to the accesibility bridge from objects vended to the UIKit accessibility framework. (flutter#4761)
```
@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.

3 participants