I have a vertically scrolling WebView inside a horizontally scrolling PageView
. Something like this:
PageView.builder(
itemCount: 5,
itemBui
I upgraded my sdk only to have this problem you described. The issue is too annoying and I came up with this rather ugly hack.
This CustomGestureRecognizer
will ignore the unwanted behavior when the event is occurring in the middle (usually where we scroll).
This does come with some over-scrolling shadows which I believe can be handled, might take some more time that's it.
class CustomGestureRecognizer extends OneSequenceGestureRecognizer {
double maxScreenOffsetX;
final double edgeMargin = 20.0;
CustomGestureRecognizer({@required this.maxScreenOffsetX});
@override
void addAllowedPointer(PointerDownEvent event) {
print("CustomGestureRecognizer: Screen Width: "+ maxScreenOffsetX.toString());
print("CustomGestureRecognizer: dx: "+event.position.dx.toString());
if (event.position.dx < edgeMargin || event.position.dx > (maxScreenOffsetX - edgeMargin)) {
print("CustomGestureRecognizer: At the Edge.");
return;
}
print("CustomGestureRecognizer: Inside Safe Zone");
startTrackingPointer(event.pointer, event.transform);
resolve(GestureDisposition.accepted);
stopTrackingPointer(event.pointer);
}
PageView Widget
PageView.builder(
itemCount: 5,
physics: CustomScrollPhysics(),
itemBuilder: (context, index) {
return WebView(
initialUrl: 'https://flutter.dev/docs',
gestureRecognizers: [
Factory(() => CustomGestureRecognizer(maxScreenOffsetX: screenWidth)),
].toSet(),
);
});
Screen Width
@override
Widget build(BuildContext context) {
screenWidth = MediaQuery.of(context).size.width;
return Scaffold(//...