Repository navigation
PageView with viewportFraction < 1.0 - GestureDetector is not working properly #23873
Copy link
Copy link
Labels
customer: googleVarious Google teamsVarious Google teamsf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.
Description
Internal: b/144873050
Hey, looks like there is a bug preventing gesture detection on right side of the widget inside page view with only one element and viewport fraction smaller than 1.0.
This is how my widget tree looks like:
column
- page view
- gesture detector
- green container
- gesture detector
- blue container
- page view
- gesture detector
- red container
Top gesture detectors (green&blue widgets) work fine, I can click anywhere and I can see debug logs in console.
Bottom gesture detector (red widget) works fine only for left half of the widget. When I click on the right half then onTap callback is not fired. Looks like something is preventing gesture detector from getting input.
flutter doctor output:
[✓] Flutter (Channel beta, v0.9.4, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] Android Studio (version 3.1)
[!] IntelliJ IDEA Community Edition (version 2018.2)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected devices (1 available)
Source code to reproduce bug:
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: Column(children: <Widget>[
Expanded(
child: ColorPages(
colors: <Color>[
Colors.green,
Colors.blue,
],
),
),
Expanded(
child: ColorPages(
colors: <Color>[
Colors.red,
],
),
),
]),
);
}
}
class ColorPages extends StatefulWidget {
final List<Color> colors;
const ColorPages({Key key, this.colors}) : super(key: key);
@override
ColorPagesState createState() {
return new ColorPagesState();
}
}
class ColorPagesState extends State<ColorPages> {
PageController _pageController;
@override
void initState() {
super.initState();
_pageController = new PageController(
viewportFraction: 0.5,
);
}
@override
Widget build(BuildContext context) {
return PageView.builder(
controller: _pageController,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
print(DateTime.now().toIso8601String() + " " + widget.colors[index].toString());
},
child: Container(
color: widget.colors[index],
),
);
},
itemCount: widget.colors.length,
);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
customer: googleVarious Google teamsVarious Google teamsf: gesturesflutter/packages/flutter/gestures repository.flutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.

Activity
zoechi commentedon Nov 3, 2018
Please add the output of
flutter doctor -v.rav3r commentedon Nov 3, 2018
@zoechi
parth181195 commentedon Dec 9, 2018
I encountered a similar issue when using viewportFraction gesture detector is not working for the page that has index 1 and page 0 is active except this scenario everything is working fine.
zoechi commentedon Feb 25, 2019
Possible duplicate of #27744
vitor-gyant commentedon Jun 11, 2019
@zoechi What is the status of this issue. I think I'm facing the same issue while trying to automatically snap clicks on pages that are not the current selected. Basically the GestureDetector that wraps the page items that have index > 0 do not trigger onTap. Any workaround ? thanks
mehmetf commentedon Nov 21, 2019
This issue is blocking one of our internal clients from shipping as their account selector relies on PageView behavior that was fixed. Is there an ETA on the reland?
vitor-gyant commentedon Nov 22, 2019
@mehmetf In which branch are you testing ?
mehmetf commentedon Nov 22, 2019
Customer found a crude workaround.
@vitor-gyant This is master. We use Flutter pretty close to ToT within Google.
vitor-gyant commentedon Nov 22, 2019
@mehmetf This issue was fixed on master and I've verified it on my side since it was affecting our app too.
mehmetf commentedon Nov 22, 2019
It was fixed in August, then the fix was reverted 10 days ago: #44778
That's why the issue was reopened. They are trying to land it again.
ankur141295 commentedon Jan 22, 2020
I am on SDK v1.12.13+hotfix.5 and still facing this issue. Is there any workaround?
LongCatIsLooong commentedon Jan 22, 2020
@ankur141295 I'm not aware of an easy workaround that would work for everyone. You could switch to the
betabranch or apply the patch locally. See https://github.com/flutter/flutter/wiki/Flutter-build-release-channels#will-a-particular-bug-fix-be-provided-in-a-hotfix-release.github-actions commentedon Aug 14, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.