Skip to content
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

customRouteBuilder's completion result type has broken in the 8.0.3 version #1913

Open
SergeShkurko opened this issue Apr 2, 2024 · 6 comments

Comments

@SergeShkurko
Copy link

SergeShkurko commented Apr 2, 2024

Now, return types don't work with customRouteBuilder correctly

Because of the last commit c2953fe. Type annotation removed from the function

/// Signature for custom router builder used by
/// [CustomRouteType]
-typedef CustomRouteBuilder = Route<T> Function<T>(
+typedef CustomRouteBuilder<T> = Route<T> Function(
  BuildContext context,
  Widget child,
  AutoRoutePage<T> page,
);

Then any reusable customRouteBuilder implementation will return Route with a dynamic type. We won't return any route with passed by router type. We need to handle generics inside the function. Like earlier

Screenshot 2024-04-03 at 03 27 02

More earlier versions work pretty

@Milad-Akarie
Copy link
Owner

@SergeShkurko try specifiying the type when returning your custom Route e.g DialogRoute<String>(....)

@LocLt-Mobile
Copy link

I have same issue.

@Skogsfrae
Copy link

@Milad-Akarie I'm running into the same problem mainly because I have a custom class that extends the CustomRoute class to avoid boilerplate code, so I can't explicitly pass the return type.

I have different CustomRoute classes with different animations that combined in the navigation stack perform different forward/back animations such as iOS modal animations styles.

class MyRoute extends CustomRoute {
  MyRoute({
    required super.page,
    ...
    super.opaque,
  }) : super(customRouteBuilder: <T>(BuildContext context,
    Widget child,
    AutoRoutePage<T> page,
  ) => MyRoutePage<T>(
              builder: (context) => child,
              settings: page,
            ));
}

I solved with this workaround that forces me to specify the return type in the navigation tree declaration too:

class MyRoute<R> extends CustomRoute {
  MyRoute({
    required super.page,
    ...
    super.opaque,
  }) : super(customRouteBuilder: (BuildContext context,
    Widget child,
    AutoRoutePage<T> page,
  ) => MyRoutePage<R>(
              builder: (context) => child,
              settings: page,
            ));
}

@Mik77o
Copy link

Mik77o commented Apr 18, 2024

We encounter the same issue for 8.0.3.

class DialogAutoRoute extends CustomRoute {
  DialogAutoRoute({
    required super.page,
    super.barrierDismissible,
    super.path,
  }) : super(
          opaque: false,
          transitionsBuilder: TransitionsBuilders.fadeIn,
          durationInMilliseconds: dialogAutoRouteDefaultDuration,
          reverseDurationInMilliseconds: dialogAutoRouteDefaultDuration,
          customRouteBuilder: <T>(context, child, routePage) => DialogRoute(
            context: context,
            builder: (_) => child,
            barrierDismissible: barrierDismissible,
            settings: routePage,
          ),
        );
}

sososdk added a commit to sososdk/auto_route_library that referenced this issue Apr 24, 2024
@vpohrebniako
Copy link

Any plans on fixing this issue?

niwaguan pushed a commit to niwaguan/auto_route that referenced this issue May 11, 2024
@Mixron469
Copy link

Still same issues for me when I upgrade auto_route to Ver. 8, with my both custom bottomSheet route and dialog route.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants