Reputation: 1231
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?
Upvotes: 18
Views: 23498
Reputation: 9
In materialApp simply set in theme
theme: ThemeData(
primarySwatch: Colors.green,
pageTransitionsTheme: const PageTransitionsTheme(
builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
},
),
),
and where you are routing use CupertinoPageRoute instead of MaterialPageRoute it will work in right way .
Upvotes: 1
Reputation: 21
Another solution is to use swipeable_page_rout. It has specific parameter onlySwipeFromEdge: false
.
Upvotes: 0
Reputation: 13545
correct way is :
MaterialApp(
.
.
.
theme: ThemeData(
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
}
)
),
.
.
.
);
Upvotes: 37
Reputation: 31
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:
MaterialApp
with BackGestureWidthTheme
with desired backGestureWidth
pageTransitionsTheme
to CupertinoPageTransitionsBuilderCustomBackGestureWidth
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
Upvotes: 1
Reputation: 277577
You are most likely looking for PageView
which allows swip to go next/previous page gesture.
Upvotes: -1