PSDTools / app

Code repository for the development of Pattonville Wallet, our school district’s app.
https://pattonville-wallet.netlify.app/
3 stars 0 forks source link

Goofy Assertion Failed Error #23

Closed ParkerH27 closed 1 year ago

ParkerH27 commented 1 year ago

Useful links:

Code:

@AutoRouterConfig(replaceInRouteName: "Page,Route")
class NavigationManager extends _$NavigationManager {
  @override
  RouteType get defaultRouteType => const RouteType.material();

  @override
  List<AutoRoute> get routes => [
        AutoRoute(
          path: "/",
          page: MyHomeRoute.page,
          children: [
            AutoRoute(page: GeneratorRoute.page, path: ""),
            AutoRoute(page: FavoritesRoute.page, path: "favorites"),
          ],
        ),
        RedirectRoute(path: "*", redirectTo: "/"),
      ];
}

ChatGPT description:

The code you have provided appears to be written in Dart language and is defining the routing configuration for an application using the auto_route package.

The get routes method is overriding the base class method to return a list of AutoRoute objects. Each AutoRoute object represents a path within the application that maps to a specific page or view.

In this example, there are two routes defined:

  • The root route / points to the MyHomeRoute page, and has two child routes defined: GeneratorRoute and FavoritesRoute.
  • The RedirectRoute is a catch-all route that redirects any invalid routes to the root route.

Here's a brief explanation of each property used in the AutoRoute and RedirectRoute objects:

  • path: A string that defines the path for the route.
  • page: The page or view that will be displayed for the route.
  • children: An optional list of child routes that can be nested under the parent route.
  • redirectTo: The path to redirect to when a route does not match any of the defined routes.

Overall, this code is setting up the routing configuration for the application, allowing users to navigate between different views based on the path they visit.

Error:

Assertion failed: file:///Users/user/.pub-cache/hosted/pub.dev/auto_route7.1.0/lib/src/route/auto_route_config.dart:419:12this[key]?.children != null
"MyHomeRoute does not have children"
See also: https://flutter.dev/docs/testing/errors

ChatGPT:

This error message indicates that there is an assertion failure in the auto_route package related to the MyHomeRoute page.

The error message suggests that the MyHomeRoute page does not have any child routes defined, but the AutoRoute configuration is trying to add child routes to it. This means that there may be a mismatch between the AutoRoute configuration and the actual structure of the pages and routes in the application.

To resolve this error, you should review the AutoRoute configuration and ensure that the MyHomeRoute page does not have any child routes defined. If MyHomeRoute is intended to have child routes, then you should update the AutoRoute configuration accordingly.

You may also want to check the documentation for the auto_route package to ensure that you are using it correctly, and review any relevant code samples or examples to get a better understanding of how to configure routes and pages within your application.

ParkerH27 commented 1 year ago

My best guess of the issue is that we are not setting up the pages that need to show when the user is routed to a particular path.

lishaduck commented 1 year ago

Yeah, I'll take another look soon. The annoying thing is that auto_route v6's docs are pretty bad. It's supposed to have a working example, but it doesn't. There is a PR (Milad-Akarie/auto_route_library#1515) that fixes a minor issue in the guide on the readme though.[^1] Admittingly, I almost agree with @tostal.[^2][^3]

[^1]: By minor, I mean so minor that even I could figure out the fix. [^2]: Trying hard not to summon a random human as I did on #16. [^3]: Look at the last bullet.

lishaduck commented 1 year ago

Exception Traceback

Here be da logs: ```console Launching lib/main.dart on Chrome in debug mode... This app is linked to the debug service: ws://127.0.0.1:49526/9cUo-eID8cI=/ws Debug service listening on ws://127.0.0.1:49526/9cUo-eID8cI=/ws πŸ’ͺ Running with sound null safety πŸ’ͺ Connecting to VM Service at ws://127.0.0.1:49526/9cUo-eID8cI=/ws ══║ EXCEPTION CAUGHT BY WIDGETS LIBRARY β•žβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β• The following assertion was thrown building KeyedSubtree-[<[]>]: Assertion failed: file:///Users/REDACTED/.pub-cache/hosted/pub.dev/auto_route-7.1.0/lib/src/route/auto_route_config.dart:419:12 this[key]?.children != null "MyHomeRoute does not have children" The relevant error-causing widget was: AnimatedSwitcher When the exception was thrown, this was the stack: dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49 throw_ dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3 assertFailed packages/auto_route/src/route/auto_route_config.dart 419:23 subCollectionOf packages/auto_route/src/router/widgets/auto_router.dart 132:60 didChangeDependencies packages/flutter/src/widgets/framework.dart 5119:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 6377:14 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 6512:36 inflateWidget packages/flutter/src/widgets/framework.dart 6524:32 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 5133:11 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 5124:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 6377:14 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 6512:36 inflateWidget packages/flutter/src/widgets/framework.dart 6524:32 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 6512:36 inflateWidget packages/flutter/src/widgets/framework.dart 6524:32 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 5133:11 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 5124:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 5133:11 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 5124:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 5133:11 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 5124:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 6377:14 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 6377:14 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 5133:11 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 5124:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 5133:11 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 5124:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 5133:11 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 5124:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 5133:11 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 5124:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/framework.dart 4993:16 performRebuild packages/flutter/src/widgets/framework.dart 5133:11 performRebuild packages/flutter/src/widgets/framework.dart 4690:5 rebuild packages/flutter/src/widgets/framework.dart 4950:5 [_firstBuild] packages/flutter/src/widgets/framework.dart 5124:11 [_firstBuild] packages/flutter/src/widgets/framework.dart 4944:5 mount packages/flutter/src/widgets/framework.dart 3953:15 inflateWidget packages/flutter/src/widgets/framework.dart 3682:18 updateChild packages/flutter/src/widgets/layout_builder.dart 135:18 layoutCallback packages/flutter/src/widgets/framework.dart 2682:19 buildScope packages/flutter/src/widgets/layout_builder.dart 153:5 [_layout] packages/flutter/src/rendering/object.dart 2300:59 packages/flutter/src/rendering/object.dart 1056:15 [_enableMutationsToDirtySubtrees] packages/flutter/src/rendering/object.dart 2300:7 invokeLayoutCallback packages/flutter/src/widgets/layout_builder.dart 228:7 rebuildIfNecessary packages/flutter/src/widgets/layout_builder.dart 313:5 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/custom_layout.dart 171:10 layoutChild packages/flutter/src/material/scaffold.dart 1080:7 performLayout packages/flutter/src/rendering/custom_layout.dart 240:7 [_callPerformLayout] packages/flutter/src/rendering/custom_layout.dart 410:14 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/proxy_box.dart 1467:11 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/layout_helper.dart 56:10 layoutChild packages/flutter/src/rendering/stack.dart 595:43 [_computeSize] packages/flutter/src/rendering/stack.dart 622:12 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/proxy_box.dart 3815:13 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/widgets/overlay.dart 856:14 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/custom_paint.dart 552:11 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/proxy_box.dart 120:7 performLayout packages/flutter/src/rendering/object.dart 2189:7 layout packages/flutter/src/rendering/box.dart 2430:11 layout packages/flutter/src/rendering/view.dart 175:7 performLayout packages/flutter/src/rendering/object.dart 2027:7 [_layoutWithoutResize] packages/flutter/src/rendering/object.dart 1020:17 flushLayout packages/flutter/src/rendering/binding.dart 516:19 drawFrame packages/flutter/src/widgets/binding.dart 865:13 drawFrame packages/flutter/src/rendering/binding.dart 381:5 [_handlePersistentFrameCallback] packages/flutter/src/scheduler/binding.dart 1289:15 [_invokeFrameCallback] packages/flutter/src/scheduler/binding.dart 1218:9 handleDrawFrame packages/flutter/src/scheduler/binding.dart 942:7 dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 48:19 internalCallback ════════════════════════════════════════════════════════════════════════════════════════════════════ ```

Conclusions

The important part is right at the top. > ```console > packages/auto_route/src/route/auto_route_config.dart 419:23 subCollectionOf > packages/auto_route/src/router/widgets/auto_router.dart 132:60 didChangeDependencies > ```

Erroring Code

Here be the code that doith not what it ought, we believe.

didChangeDependencies

It's from package:auto_route/src/router/widgets/auto_router.dart. ```dart /// State implementation of [AutoRouter] class AutoRouterState extends State { ... @override void didChangeDependencies() { super.didChangeDependencies(); if (_controller == null) { final parentRouteData = RouteData.of(context); final parentScope = RouterScope.of(context, watch: true); _inheritableObserversBuilder = () { var observers = widget.navigatorObservers(); if (!widget.inheritNavigatorObservers) { return observers; } var inheritedObservers = parentScope.inheritableObserversBuilder(); return inheritedObservers + observers; }; _navigatorObservers = _inheritableObserversBuilder(); _parentController = parentScope.controller; _controller = NestedStackRouter( parent: _parentController, key: parentRouteData.key, routeData: parentRouteData, navigatorKey: widget.navigatorKey, routeCollection: _parentController.routeCollection.subCollectionOf( parentRouteData.name, ), pageBuilder: _parentController.pageBuilder, ); _parentController.attachChildController(_controller!); _controller!.addListener(_rebuildListener); } } ... } ```

routeCollection

Specifically, the issue is caused by this line of code: > ```dart > routeCollection: _parentController.routeCollection.subCollectionOf( > parentRouteData.name, > ), > ```

This code calls the method subCollectionOf.

subCollectionOf

This method is defined in package:auto_route/src/route/widgets/auto_route_config.dart. ```dart /// Holds a single set of config-entries /// /// it makes accessing routes by name easier /// by creating a Map on init /// /// it also has some helper-methods and getters /// to deal with config-entries /// /// Mainly used by [RouteMatcher] class RouteCollection { ... /// Returns the sub route-entries of the route corresponding with [key] /// /// Throws and error if corresponding route has not children RouteCollection subCollectionOf(String key) { assert(this[key]?.children != null, "$key does not have children"); return this[key]!.children!; } ... } ```

Us

So what does this have to do with us?

Our Code

Here's our AutoRouterConfig, called NavigationManager. ```dart @AutoRouterConfig(replaceInRouteName: "Page,Route") class NavigationManager extends _$NavigationManager { @override RouteType get defaultRouteType => const RouteType.material(); @override List get routes => [ AutoRoute( path: "/", page: MyHomeRoute.page, children: [ AutoRoute(page: GeneratorRoute.page, path: ""), AutoRoute(page: FavoritesRoute.page, path: "favorites"), ], ), RedirectRoute(path: "*", redirectTo: "/"), ]; } ```

Usage of NavigationManager

Here's where we hook into the AutoTabsRouter, hopefully through NavigationManager. ```dart @RoutePage() class MyHomePage extends StatelessWidget { ... @override Widget build(BuildContext context) { ... return LayoutBuilder( builder: (context, constraints) { return AutoTabsRouter( routes: const [ GeneratorRoute(), FavoritesRoute(), ], builder: (context, child) { final tabsRouter = AutoTabsRouter.of(context); // The container for the current page, with its background color // and subtle switching animation. var mainArea = ColoredBox( color: colorScheme.surfaceVariant, child: AnimatedSwitcher( duration: Duration(milliseconds: 200), child: AutoRouter(), ), ); if (constraints.maxWidth < 450) { return Scaffold( ... body: mainArea, bottomNavigationBar: BottomNavigationBar( currentIndex: tabsRouter.activeIndex, onTap: tabsRouter.setActiveIndex, items: [ BottomNavigationBarItem( label: 'Home', icon: Icon(Icons.home), ), BottomNavigationBarItem( label: 'Favorites', icon: Icon(Icons.favorite), ), ], ), ); } return Scaffold( body: Row( children: [ SafeArea( child: NavigationRail( extended: constraints.maxWidth >= 600, destinations: [ NavigationRailDestination( icon: Icon(Icons.home), label: Text('Home'), ), NavigationRailDestination( icon: Icon(Icons.favorite), label: Text('Favorites'), ), ], selectedIndex: tabsRouter.activeIndex, onDestinationSelected: tabsRouter.setActiveIndex, ), ), Expanded(child: mainArea), ], ), ); } }, ); }, ); } } ```

AutoTabsRouter

AutoTabsRouter's factory is just an opaque wrapper for _AutoTabsRouterIndexedStack. ```dart // ----------------------------------------------------------- class _AutoTabsRouterIndexedStack extends AutoTabsRouter { ... const _AutoTabsRouterIndexedStack({ Key? key, required List routes, this.lazyLoad = true, this.duration = const Duration(milliseconds: 300), this.curve = Curves.ease, this.builder, this.transitionBuilder = _defaultTransitionBuilder, int homeIndex = -1, bool inheritNavigatorObservers = true, NavigatorObserversBuilder navigatorObservers = AutoRouterDelegate.defaultNavigatorObserversBuilder, }) : super._( key: key, routes: routes, inheritNavigatorObservers: inheritNavigatorObservers, navigatorObservers: navigatorObservers, homeIndex: homeIndex, ); ... } ```

And...

I have no idea! If you happen to know anything, please speak up. The backtraces aren't especially...easy to wade through. I didn't see any of our code, in fact. Hmm, aren't we initiating it?

CC: @ParkerH27 @PetalCat

lishaduck commented 1 year ago

Boy, do I hate CSS! It hid the start of the error message!

No TabController for TabBar.
When creating a TabBar, you must either
provide an explicit TabController using the
"controller" property, or you must ensure that
there is a DefaultTabController above the TabBar.
In this case, there was neither an explicit
controller nor a default controller.
See also: https://flutter.dev/docs/testing/errors
lishaduck commented 1 year ago

Quick search:

lishaduck commented 1 year ago

Doing more looking, and it seems I've isolated a different patch of code:

@RoutePage()
class MyHomePage extends StatelessWidget {
  ...
            // The container for the current page, with its background color
            // and subtle switching animation.
            var mainArea = ColoredBox(
              color: colorScheme.surfaceVariant,
              child: AnimatedSwitcher(
                duration: Duration(milliseconds: 200),
                child: AutoRouter(),
              ),
            );
  ...
}

Specifically, child: AutoRouter().

lishaduck commented 1 year ago

Flutter 3.10 has a better error message. Barely. Net even enough for me to post it, because I already figured that part out.

lishaduck commented 1 year ago

Yahoo! As of 3656be1972a7af49f04809240634e6fcd4995206, the app works. Next up, merge in Very Good Core for all of the niceties, write some tests, and make sure the basic app has support for translating to Spanish.[^1] Well, back to #9!

[^1]: Which is why I want to merge in VGCβ€”i18n. And tests. And better CI with pana. And more lints. Well, maybe it's not just i18n. Oh yeah, and a structure, though maybe Riverpod won't like it. It uses Bloc. Oh, and before I forget, it needs some modification to work with flutter_launcher_icons, which they suggest using. ~Yikes.~ Now the footnote is ~too long~ still too short.