-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Internal: b/155674981
When I use GestureDetector and put behavior = translucent, I cannot tap on anything bellow it. Also when I use GestureDetector and put behavior lets say opaque and have RawMaterialButton as a child, taps on button are registered on Button but not on GestureDetector and expected behavior in this case would be that taps do not pass to the child.
Example:
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',
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Stack(
children: <Widget>[
new Positioned(
left: 0.0,
right: 0.0,
top: 200.0,
bottom: 200.0,
child: new TextField(
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.blue,
),
),
),
new Positioned.fill(
child: new GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: (){
print("Clicked gesture");
},
),
),
// new Positioned.fill(
// child: new GestureDetector(
// behavior: HitTestBehavior.opaque,
// onTap: (){
// print("Clicked gesture");
// },
// child: new RawMaterialButton(
// child: new Text(
// 'BUTTON',
// textAlign: TextAlign.center,
// ),
// onPressed: (){
// print("Clicked button");
// },
// ),
// ),
// ),
],
),
);
}
}In this example, I would expect that GestureDetector receives tap input, but also that TextField gets focus, but what happens is that taps are registered in GestureDetector, but nothing passes to the TextField. If I comment out GestureDetector part, TextField works.
Further, you can comment out first two widgets in stack and uncomment last one to check other issue- when GestureDetector has child. I would expect that no tap is passed to child but child receives input and GestureDetector does not.
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v0.5.5-pre.10, on Mac OS X 10.13.4 17E202, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4)
[✓] Android Studio (version 3.1)
[!] IntelliJ IDEA Ultimate Edition (version 2018.1.2)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected devices (2 available)