-
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
Cupertino back gesture are disabled when using PageRouteBuilder #47441
Comments
Related to kalismeras61/flutter_page_transition#19 |
This is so important! It's also the reason, why the animations package doesn't support iOS swipe back gesture :( |
Having the same issue, using the Animations package to do a fadethrough to the new route. Can't seem to swipe back on iOS!
I guess I'll have to stick to no page transitions for now, until a fix is found. |
Have you tried something like wrapping the page being pushed in a GestureDetector? It seems like it could be a makeshift solution. (I have implemented a way to change the direction of the transition but that can be ignored.)
Unfortunately this pops from a swipe in either direction, but I'm sure a combination of one of GestureDetector callback options and properties of the details will make swipe direction detectable. Also this swipedetector package might replace the GestureDetector, or I might even experiment with this swipe_back_detector specifically made for custom routes made with PageRouteBuilder (see example they give). |
You can use a custom For iOS, the default Here's some sample code for the class CustomPageRouteBuilder<T> extends PageRoute<T> {
final RoutePageBuilder pageBuilder;
final PageTransitionsBuilder matchingBuilder = const CupertinoPageTransitionsBuilder(); // Default iOS/macOS (to get the swipe right to go back gesture)
// final PageTransitionsBuilder matchingBuilder = const FadeUpwardsPageTransitionsBuilder(); // Default Android/Linux/Windows
CustomPageRouteBuilder({this.pageBuilder});
@override
Color get barrierColor => null;
@override
String get barrierLabel => null;
@override
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
return pageBuilder(context, animation, secondaryAnimation);
}
@override
bool get maintainState => true;
@override
Duration get transitionDuration => Duration(milliseconds: 900); // Can give custom Duration, unlike in MaterialPageRoute
@override
Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
return matchingBuilder.buildTransitions<T>(this, context, animation, secondaryAnimation, child);
}
} Then to go to a new page: GestureDetector(
onTap: () => Navigator.push(
context,
CustomPageRouteBuilder(pageBuilder: (context, animation, secondaryAnimation) => NewScreen()),
),
child: ...,
) |
Thanks, @rohan-kadkol, it's working with me after
|
We Can use CustomPageRouteBuilder to Achieve this
|
Use case
I am using
PageRouteBuilder
to add fade transition to some of my routes.I've noticed however that the swipe to go back on IOS is not working when doing so! Which is something I'm used to as an IOS user.
Which left me with either choosing a very pleasing to the eye page transitions or better user experience.
Proposal
I was thinking that exposing the private classes
_CupertinoBackGestureDetector
and_CupertinoBackGestureController
which are used in theCupertinoPageRoute
to achive the swipe to go back function, or improving thePageRouteBuilder
to support that feature, will be a great thing to have!The text was updated successfully, but these errors were encountered: