In my app I have extended MaterialPageRoute to disable page transition animations.
class NoAnimationMaterialPageRoute<T> extends MaterialPageRoute<T> {
NoAnimationMaterialPageRoute({
@required WidgetBuilder builder,
RouteSettings settings,
bool maintainState = true,
bool fullscreenDialog = false,
}) : super(
builder: builder,
maintainState: maintainState,
settings: settings,
fullscreenDialog: fullscreenDialog,
);
@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
return child;
}
}
This works as expected, however, it has broken the iOS swipe back gesture. How do I re-enable it? I don't care about animating anything, I just want swipe to go back to work.
if you don't need any animation you can do like that:
class NoAnimationMaterialPageRoute<T> extends MaterialPageRoute<T> {
NoAnimationMaterialPageRoute({
@required WidgetBuilder builder,
RouteSettings settings,
bool maintainState = true,
bool fullscreenDialog = false,
}) : super(
builder: builder,
maintainState: maintainState,
settings: settings,
fullscreenDialog: fullscreenDialog,
);
@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
var animation1 = Tween(begin: 1.0, end: 1.0).animate(animation);
final theme = Theme.of(context).pageTransitionsTheme;
return theme.buildTransitions<T>(
this,
context,
animation1,
secondaryAnimation,
child,
);
}
}
But it gives you only the back swipe functionality, without visible effect, you wanted to have the visual effect of gesture, you will need to make your own version of CupertinoPageTransition
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With