New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
auto_route 2.0.0 is out! #486
Comments
How to generate navigation helpers in this version? |
Awesome work! I've updated here on my side and it's working fine so far. Should we create a release on github too? |
Awesome work, but #421 is still broken :-( |
Great work. I am very much hyped for this 😍 The sentence |
@jlnrrg Using The AutoTabsRouter widget is enough now, I just want it to decouple things. |
Great work! Thanks for your time in this project @Milad-Akarie ! |
@Milad-Akarie did you leave the |
@jlnrrg nah I just missed it while cleaning up, I'll make sure it's removed. |
Hi, I got this error after updating to v2.0.0 The argument type 'List<FirebaseAnalyticsObserver>' can't be assigned to the parameter type 'List<NavigatorObserver> Function()'. |
@brizaldi please share your code. It looks to me as if you try to assign a List to a Function that returns such Lists. |
@jlnrrg this code works on the old version v1.0.2 MaterialApp.router(
routerDelegate: _appRouter.delegate(
navigatorObservers: [
FirebaseAnalyticsObserver(
analytics: getIt<FirebaseAnalytics>(),
),
],
),
...
); Edit: nevermind, solved it after modify the code like this navigatorObservers: () => [
FirebaseAnalyticsObserver(
analytics: getIt<FirebaseAnalytics>(),
),
], |
@brizaldi great to hear that you figured it out. But I still argue for a documentation how to implement RouteObserver using auto_route and/or implementing an observer in the example project. |
@Milad-Akarie take your example above, is there a way to push the book details route above everything else? The pushed route should not be wrapped in the parent route. |
@essarn hey, thats a common use case: you have a list view in a tab For me, i've used 2 possible solutions before:
or
I prefer option 1. However, if your Details page is going to be called in multiple places in ur app (like from other tabs), then option 2 is better |
@theweiweiway thanks for the quick answer but I have some further questions. I'm not a fan of the first solution because it doesn't animate nicely with the page transition and the second solution breaks the nice url structure you get with nested routes. So is there a way to move the details route to the root level but keep the parent's path prefix it would have had as a child? |
@essarn what speaks against pushing the route above the tabRouter |
@essarn for the 1st solution, by not animating nicely do you mean the bottom navigation bar just disappears and re-appears? To fix that I did AnimatedOpacity(
duration: Duration(milliseconds: 200),
opacity: _isNavBarShowing() ? 1 : 0,
child: BottomNavBar(),
) so that the nav bar animates in and out. This might not be what you want if you want the transition to "cover" the navbar while animated in. If you want to "cover" the navbar, then you'd probably need a separate router. Not sure how to keep the same URL structure in that case though. |
@Milad-Akarie can you please put this example-app repository up? The one with bottom navigation as shown in gif. It would be very helpful as I was lowkey struggling with even the old one, let alone with the new updates. Thank you so much. |
@akshayspeaks the example is here https://github.com/Milad-Akarie/auto_route_library/tree/master/auto_route/example/lib |
I don't quite understand what it means by
I'm currently doing return MaterialApp(
title: 'Dr. Words',
theme: AppTheme.lightTheme,
onGenerateRoute: AppRouter().onGenerateRoute,
navigatorKey: StackedService.navigatorKey,
debugShowCheckedModeBanner: false,
); but after upgrading to the latest version of this package, |
Actually I figured it out, the stacked_services listing on pub.dev has some information about using its generated onGenerateRoute to accomplish the purpose. It seems that package preferred to implement auto_route internally to have one less package dependency. |
With the new implantation of route observer, did someone figure out, how to implement example widget stolen from mediumimport 'package:flutter/material.dart';
class RouteAwareWidget extends StatefulWidget {
const RouteAwareWidget({Key? key, required this.child}) : super(key: key);
final Widget child;
@override
State<RouteAwareWidget> createState() => RouteAwareWidgetState();
}
// Implement RouteAware in a widget's state and subscribe it to the RouteObserver.
class RouteAwareWidgetState extends State<RouteAwareWidget> with RouteAware {
@override
void didPopNext() {
debugPrint('didPopNext');
}
/// Called when the current route has been pushed.
@override
void didPush() {
debugPrint('didPush');
}
/// Called when the current route has been popped off.
@override
void didPop() {
debugPrint('didPop');
}
/// Called when a new route has been pushed, and the current route is no
/// longer visible.
@override
void didPushNext() {
debugPrint('didPushNext');
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
routeObserver.subscribe(this, ModalRoute.of(context)); //<- how to obtain routeObserver?
}
@override
void dispose() {
routeObserver.unsubscribe(this);
super.dispose();
}
@override
Widget build(BuildContext context) => widget.child;
}
|
@jlnrrg I read your comment from the notifications and I just couldn't find it anymore lol _routerScope = RouterScope.of(context)
if(_routerScope != null) {
// all observers
_routerScope!.navigatorObservers;
// or
_routerScope!.firstObserverOfType<RouteObserver>()
.subscribe(routeAware, route)
} does that fix your problem? |
I don't understand... Please, how exactly did you resolve the differences and the deprecated onGenerateRoute, because I am facing the same challenge here. |
See the example here: https://github.com/FilledStacks/stacked/blob/master/packages/stacked_services/example/lib/main.dart |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions |
Hello everyone, I apology for not being active lately, it's because I've been working on AutoRoute 2.0.0.
working with nested routers is more friendly now, I hope you enjoy the update.
breaking changes
enhancements
The text was updated successfully, but these errors were encountered: