stacked icon indicating copy to clipboard operation
stacked copied to clipboard

How to use CustomRoute

Open ajnaf opened this issue 5 years ago • 19 comments

I used the same class of the transitionBuilder in the auto route it used to work until i migrated to the null saftey packege

ajnaf avatar Apr 05 '21 05:04 ajnaf

AutoRoute isn't compatible with stacked anymore. Stacked has its own router functionality that you can see in this video

FilledStacks avatar Apr 05 '21 05:04 FilledStacks

Yes i know , i migrated to the stacked route and using the stacked generator but couldn't find any documentation on the customRoute

ajnaf avatar Apr 05 '21 06:04 ajnaf

It's the same as the AutoRoute one. I moved the code over from AutoRoute into stacked. I'll add some documentation when I get some time.

FilledStacks avatar Apr 05 '21 06:04 FilledStacks

You forgot about the TransitionsBuilders class so i add it in my project it used to work before the null saftey but it won't work anymore I don't know why

ajnaf avatar Apr 05 '21 07:04 ajnaf

stacked/src/code_generation/router/transitions_builders.dart i can't use this class not the same as auto route is there a different way?

ajnaf avatar Apr 05 '21 07:04 ajnaf

image

ajnaf avatar Apr 05 '21 07:04 ajnaf

I faced the same problem,

CustomRoute( page: TestView, transitionsBuilder: TransitionsBuilders.fadeIn, ), CustomRoute( page: UpdateNoteView, transitionsBuilder: TransitionsBuilders.zoomIn, ), CustomRoute( page: TestGallery, transitionsBuilder: TransitionsBuilders.slideRightWithFade, ),

i can't use anymore

@FilledStacks

okursoftware avatar Apr 07 '21 10:04 okursoftware

Discovered that NavigationService has replaceWithTransition and navigateWithTransition methods but both require the actual Views instead of Routes. Moreover, I tested the built-in transition animations that came with the methods and some of them were buggy (fade transition, which I need for my project, seems to just be the regular Material transition). Just wanted to raise this even though it is a minor/cosmetic issue.

BrylleGomez avatar Apr 22 '21 21:04 BrylleGomez

Maybe it's not exported. Let me check if it's still there in the package. I never built any of this in directly.

FilledStacks avatar Apr 28 '21 16:04 FilledStacks

I just added the transition builders to the exports in stacked.dart. You should be able to import now @okursoftware

FilledStacks avatar Apr 28 '21 16:04 FilledStacks

Using custom route gives this error:

[SEVERE] stacked_generator:stackedRouterGenerator on lib/app/router.dart:

type 'Null' is not a subtype of type 'String'

Here is the configuration:

@StackedApp(
  routes: [
    CustomRoute(
      page: SplashView,
      initial: true,
      transitionsBuilder: TransitionsBuilders.slideRightWithFade,
      durationInMilliseconds: 300,
    ),
  ]
)
class App {}

What's interesting is that the issue only happens with CustomRoute.

elhe26 avatar Apr 30 '21 22:04 elhe26

Using custom route gives this error:

[SEVERE] stacked_generator:stackedRouterGenerator on lib/app/router.dart:

type 'Null' is not a subtype of type 'String'

Here is the configuration:

@StackedApp(
  routes: [
    CustomRoute(
      page: SplashView,
      initial: true,
      transitionsBuilder: TransitionsBuilders.slideRightWithFade,
      durationInMilliseconds: 300,
    ),
  ]
)
class App {}

What's interesting is that the issue only happens with CustomRoute.

So it's not just me 😂😂😂 If you don't add the transitionBuilders it works but then what is the use without it

ajnaf avatar Apr 30 '21 22:04 ajnaf

CustomRoute(page: LoginView,transitionsBuilder: TransitionsBuilders.zoomIn), The import problem is solved, but,

I encountered such an error when I ran build_runner

[SEVERE] stacked_generator:stackedRouterGenerator on lib/app/app.dart:

NoSuchMethodError: The method 'startsWith' was called on null.
Receiver: null
Tried calling: startsWith("dart")

okursoftware avatar May 03 '21 20:05 okursoftware

@FilledStacks How do we add custom TransitionBuilders? I tried to add but the generated app.router.dart file is not importing the custom transition builder file.

saileshbro avatar Aug 17 '21 18:08 saileshbro

@FilledStacks How do we add custom TransitionBuilders? I tried to add but the generated app.router.dart file is not importing the custom transition builder file.

@FilledStacks can you take a look at this please?

calebdeji avatar Oct 12 '21 20:10 calebdeji

@calebdeji we don't have custom transition builders. We will be working on that for Stacked v3

FilledStacks avatar Jan 19 '22 03:01 FilledStacks

@FilledStacks, please make sure I can add my ModalsPageRoute.

Like this
Route<T> modalsPageRoute<T>(
  BuildContext context,
  Widget child,
  CustomPage<T> page,
) {
  return MaterialWithModalsPageRoute(
    fullscreenDialog: page.fullscreenDialog,
    settings: page,
    builder: (_) => child,
  );
}

CustomRoute(
  customRouteBuilder: modalsPageRoute,
  path: '/profile',
  page: ProfilePage,
),

ziqq avatar Sep 19 '22 08:09 ziqq

@ziqq you can make sure and then tell me if you can't.

FilledStacks avatar Sep 19 '22 12:09 FilledStacks

The doc for this functionality has been created.

FilledStacks avatar May 16 '23 06:05 FilledStacks