Go back feature works only on the edge of the screen on iPhone. How can I swipe to previous page from anywhere on the screen?
5 Answers
correct way is :
MaterialApp(
.
.
.
theme: ThemeData(
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
}
)
),
.
.
.
);
-
I don't know how to implement this, May you show me an example about that? May 27, 2020 at 11:47
-
why does not work on my application. using flutte version 1.25.0-9.0.pre.1– GeekLeiJan 30, 2021 at 14:50
-
then what ? its not work ,
Navigator.of(context).push( PageRouteBuilder( pageBuilder: (_, animation, __) { return FadeTransition( opacity: animation, child: MoviePage(movie: movie), ); }, ), );
Mar 12 at 2:02
Use CupertinoPageRoute to make it work on Android.
-
1Could you explain? I try to use
CupertinoPageRoute
- it provides animation in iOS style. But swipe left to right for returning to previous page still doesn't work Feb 20, 2019 at 8:48
If I understood correctly the problem is how to set custom width of the iOS back swipe gesture area? So one of the possible solutions is to use this package: cupertino_back_gesture.
Explanation from authors of package:
To change width of area where the user can start back swipe for the whole app:
- Wrap your
MaterialApp
withBackGestureWidthTheme
with desiredbackGestureWidth
- set iOS builder of
pageTransitionsTheme
toCupertinoPageTransitionsBuilderCustomBackGestureWidth
import 'package:cupertino_back_gesture/cupertino_back_gesture.dart';
BackGestureWidthTheme( backGestureWidth: BackGestureWidth.fraction(1 / 2), child: MaterialApp(
theme: ThemeData(
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilderCustomBackGestureWidth(),
},
),
),
home: MainPage(),
),
)
Example app can be found on github.com
Another solution is to use swipeable_page_rout. It has specific parameter onlySwipeFromEdge: false
.