You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It bothers me that I have to define the return type on the call site of push<...>(). While at the same time the actual type of the return value is defined on the call site of pop(). Assuming I only return a single static type across all calls to pop() for a single route, it would be nice to have the static type on the call to push().
My first idea would be to generate a extension class on StackRouter where each route gets a push function with the actual return type.
For example if I have a detail screen route with some return type, the generator would emit this code:
extensionStaticReturnTypesForPushonStackRouter {
Future<MyReturnType?> pushDetailScreen(DetailScreenRoute route) async {
// call router to push route and cast return value
}
}
Which could be used like this:
final result =await context.router.pushDetailScreen(DetailScreenRoute(....));
// result is of type MyReturnType?
Before version 9, I would suggest using the type parameter of @RoutePage, but the parameter has been removed, so the information is no longer available for a hypothetical code generator. Searching for all pop() calls is probably a bad idea, so I don't really know how to implement this feature at the moment.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
It bothers me that I have to define the return type on the call site of
push<...>()
. While at the same time the actual type of the return value is defined on the call site ofpop()
. Assuming I only return a single static type across all calls topop()
for a single route, it would be nice to have the static type on the call topush()
.My first idea would be to generate a extension class on
StackRouter
where each route gets a push function with the actual return type.For example if I have a detail screen route with some return type, the generator would emit this code:
Which could be used like this:
Before version 9, I would suggest using the type parameter of
@RoutePage
, but the parameter has been removed, so the information is no longer available for a hypothetical code generator. Searching for allpop()
calls is probably a bad idea, so I don't really know how to implement this feature at the moment.Beta Was this translation helpful? Give feedback.
All reactions