-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
MaterialPageRoute incorrectly applies CupertinoPageRoute’s transition animation on iOS #95764
Comments
That certainly looks like a fidelity issue - PageTransitionsTheme does specify transition builders, but not durations and other parameters of these transitions. |
This could be a weird one to figure out. After a short bit of pondering, I can't imagine a way of doing this that both 1) wouldn't suck, and 2) wouldn't break some public APIs folks out there are using to configure durations. I think the core problem is that the current API for configuring durations on routes is not straightforward, and not consistent:
I feel like the ways this could be solved would be to either:
I'm blocked on some other stuff I was working on atm so I'm gonna put some thoughts together on the options we have. |
I haven't looked closely at it, but it seems, we could just add more properties to PageTransitionsTheme, which MaterialPageRoute already uses |
Well yes, and that probably is going to be what makes sense to do, but we'd also have to expose some part of the route where we can actually build the animation controller with access to a context from which you can pull the theme values. This would be the path of least resistance: @override
Duration get transitionDuration {
final ThemeData theme = Theme.of(navigator!.context);
return theme.pageTransitionsTheme.something.duration(theme.platform);
}
@override
Duration get reverseTransitionDuration {
final ThemeData theme = Theme.of(navigator!.context);
return theme.pageTransitionsTheme.something.reverseDurations(theme.platform);
}
@override
Color? get barrierColor {
final ThemeData theme = Theme.of(navigator!.context);
return fullscreenDialog ? null : theme.pageTransitionsTheme.something.barrierColor(theme.platform);
} The null checks on the The alternative I was imagining would be worth considering, would be something more like: @override
AnimationController buildAnimationController(BuildContext context, TickerProvider vsync) {
// Routes that currently take in a custom animationController could just return it here
// The context here is the navigator context, but this method would only get called once during `install`
final ThemeData theme = Theme.of(context);
return AnimationController(
duration: theme.pageTransitionsTheme.something.duration(theme.platform),
reverseDuration: theme.pageTransitionsTheme.something.reverseDuration(theme.platform),
vsync: vsync
);
}
@override
Color? buildBarrierColor(BuildContext context) {
final ThemeData theme = Theme.of(context); // This would be the `ModalScope`'s context, which feels more correct to me
return fullscreenDialog ? null : theme.pageTransitionsTheme.something.barrierColor(theme.platform);
} |
After doing some more digging, I've found that the |
It's the same issue for the web as well. |
If you use
MaterialPageRoute
, Flutter automatically adapts the transition animation depending on the platform: on Android it uses a transition fromMaterialPageRoute
, and on iOS fromCupertinoPageRoute
. It's a good idea, but the implementation needs to be improved.Although
MaterialPageRoute
adapts the transition animation depending on the platform, it uses the wrong animation speed for transition fromCupertinoPageRoute
: instead of 400 ms animation speed required forCupertinoPageRoute
, it uses 300 ms animation speed which is only suitable forMaterialPageRoute
. It seems to be no big deal, but this makes CupertinoPageRoute's behavior feel completely different than it should. It doesn't feel like a native transition animation.I have a question: is it normal
MaterialPageRoute
behavior on iOS or is it a bug? What was the point of using a transition animation fromCupertinoPageRoute
inMaterialPageRoute
on iOS?By the way, in one of the next releases there will be an improvement
CupertinoPageRoute
’s transition animation. Issue: #95511, PR: #95537. Briefly, theCupertinoPageRoute
transition animation will have a newbarrierColor
like in native iOS. With the current implementation of how the transition animation works depending on platform, I guess those developers who are usingMaterialPageRoute
for both platforms won't be able to notice these improvements.The text was updated successfully, but these errors were encountered: