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

Is it possible to add page transition animation to FlowBuilder? #29

Closed
e200 opened this issue Feb 7, 2021 · 2 comments
Closed

Is it possible to add page transition animation to FlowBuilder? #29

e200 opened this issue Feb 7, 2021 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@e200
Copy link

e200 commented Feb 7, 2021

Is your feature request related to a problem? Please describe.
Same as title.

Describe the solution you'd like
Would be nice to have page transition animations like we have when using Navigator's methods.

Describe alternatives you've considered
We could provide a MaterialPageRoute or equivalent in place of MaterialPage.

@felangel felangel self-assigned this Feb 22, 2021
@felangel felangel added the enhancement New feature or request label Feb 22, 2021
@felangel
Copy link
Owner

felangel commented Feb 22, 2021

Hi @e200 👋
Thanks for opening an issue!

You can definitely use custom PageTransitions with FlowBuilder 👍

class MyPage<T> extends Page<T> {
  const MyPage({required this.child, LocalKey? key}) : super(key: key);

  final Widget child;

  @override
  Route<T> createRoute(BuildContext context) {
    return PageRouteBuilder(
      settings: this,
      pageBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> secondaryAnimation,
      ) {
        return ScaleTransition(scale: animation, child: child);
      },
    );
  }
}

Then you can use your custom Page instead of MaterialPage:

return FlowBuilder<MyFlowState>(
      state: FlowState.initial,
      onGeneratePages: (state, pages) {
        // We can use `MyPage` with our custom transition animation :)
        return [MyPage(child: MyWidget())];
      },
    );

Let me know if that helps! 👍

@felangel felangel added question Further information is requested and removed enhancement New feature or request labels Feb 22, 2021
@e200
Copy link
Author

e200 commented Feb 23, 2021

It works! Many thanks @felangel.

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

No branches or pull requests

2 participants