Manage you project Routes. Create nested routes. Simply navigation without context to your pages. Change only one sub widget in your page when navigating to new route.
MIT License
87
stars
22
forks
source link
Error: Bad state: No element when trying access child.routeName on builderChild #109
I'm trying to access the route name in builderChild but I'm getting a bad state error.
Stack trace:
Example code (click to expand):
```dart import 'package:flutter/material.dart'; import 'package:qlevar_router/qlevar_router.dart'; class App extends StatelessWidget { const App({super.key}); @override Widget build(BuildContext context) { return MaterialApp.router( routeInformationParser: const QRouteInformationParser(), routerDelegate: QRouterDelegate( AppRoutes().routes, initPath: '/dash', ), ); } } class AppRoutes { static const String homePage = 'Home Page'; final routes = [ QRoute.withChild( path: '/dash', builderChild: (child) { final routeName = child.routeName; return Scaffold( appBar: AppBar( title: Text(routeName), ), body: child, ); }, children: [ const QRoute( name: homePage, path: '/', builder: HomePage.new, ), ], ), ]; } class HomePage extends StatelessWidget { const HomePage({super.key}); @override Widget build(BuildContext context) { return const Center(child: Text('Home')); } } void main() { runApp(const App()); } ```