Introduction
GetX provides a powerful and flexible system for page transitions. You can choose from several built‑in animations or create your own custom transitions. Transitions can be defined per route (in GetPage) or overridden when calling Get.to. You can also control duration, curve, and even use your own Transition widget. This guide covers all the options to make your app’s navigation smooth and engaging.
Built‑in Transitions
GetX comes with a set of ready‑to‑use transitions that you can apply directly. Here are the most common ones:
Transition.fade– A simple cross‑fade animation.Transition.fadeIn– Fade in the new page from transparent to opaque.Transition.rightToLeft– Slide the new page in from the right (default).Transition.leftToRight– Slide the new page in from the left.Transition.upToDown– Slide the new page down from the top.Transition.downToUp– Slide the new page up from the bottom.Transition.zoom– Scale the new page from small to normal.Transition.cupertino– iOS‑style slide (similar to CupertinoPageRoute).Transition.native– Uses the platform’s default transition (iOS/Android).Transition.size– Grows the new page from the source location.Transition.noTransition– No animation.
Using Transitions with Named Routes
The most common way to set a transition is inside the GetPage definition. You can also set a default transition globally.
Transitions with Get.to (Widget‑Based Navigation)
When using Get.to, you can pass the transition parameters directly.
Custom Transitions
For complete control, you can create a custom transition by implementing the CustomTransition class or using the customTransition property in GetPage. You’ll receive the animation controller and the child widget.
You can also use Get.to with a custom transition by passing a CustomTransition object.
Transition Duration & Curve
You can customize the animation duration and curve for any transition. If not set, the default duration is 300ms and the curve is Curves.linear (or platform defaults).
Global Defaults
Set a default transition for all routes in GetMaterialApp. You can also set a default duration and curve.
Reversing Transitions on Pop
When you navigate back, the transition automatically reverses. The reverse animation uses the same settings (duration, curve). For custom transitions, you can use secondaryAnimation to animate the outgoing page.
Advanced: Animated Switcher Style
If you need more complex animations (e.g., shared element transitions), you can combine GetX navigation with Flutter’s Hero widget. Hero animations work seamlessly with GetX navigation because the routes are pushed onto the same navigator.
Best Practices
- Use consistent transitions – For a cohesive experience, pick a default transition that matches your app’s style.
- Keep durations short – 250–400ms is typical; longer durations can feel sluggish.
- Use curves for polish –
Curves.easeInOutorCurves.easeOutCubicgive a natural feel. - Test on both platforms – iOS users expect slide, Android users may expect fade or slide from right.
- Avoid heavy custom transitions – Keep them simple to maintain performance.
Common Mistakes
- ❌ Setting both
transitionandcustomTransition– They conflict; use only one. ✅ Choose either built‑in or custom. - ❌ Using
transition: Transition.cupertinoon Android – It may look out of place; considerTransition.rightToLeftfor Android. ✅ Test on both platforms. - ❌ Forgetting to set
transitionDuration– The default may be too fast or too slow for your effect. ✅ Explicitly set a duration that fits your design. - ❌ Using
Obxinside the transition builder – Might cause rebuilds; not recommended.
FAQ
- Q: Can I have different transitions for push and pop?
A: Not directly, but you can create a custom transition that checks the direction usinganimation.statusand applies different animations. - Q: How do I make a transition that slides from the bottom?
A: UseTransition.upToDownfor entering from top orTransition.downToUpfor from bottom. You can also create a custom slide. - Q: Can I combine multiple transitions (e.g., fade + scale)?
A: Yes, inside a custom transition you can combineFadeTransitionandScaleTransitionor useAnimatedBuilderto compose. - Q: Does GetX support shared element transitions?
A: It supports Flutter’s nativeHerowidget without any extra code. Just use matching tags. - Q: How to remove all transitions?
A: Usetransition: Transition.noTransitionin your route or setdefaultTransition: Transition.noTransition.
Conclusion
GetX navigation transitions give you the flexibility to create beautiful page animations with minimal effort. Whether you use the built‑in transitions or craft your own, you can easily control the look and feel of your app’s navigation. Combine them with GetX’s other features for a complete routing solution.