-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/f: 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.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
Description
docs say
flutter/packages/flutter/lib/src/rendering/proxy_box.dart
Lines 146 to 160 in fc9addb
| /// How to behave during hit tests. | |
| enum HitTestBehavior { | |
| /// Targets that defer to their children receive events within their bounds | |
| /// only if one of their children is hit by the hit test. | |
| deferToChild, | |
| /// Opaque targets can be hit by hit tests, causing them to both receive | |
| /// events within their bounds and prevent targets visually behind them from | |
| /// also receiving events. | |
| opaque, | |
| /// Translucent targets both receive events within their bounds and permit | |
| /// targets visually behind them to also receive events. | |
| translucent, | |
| } |
but the actual behavior seems to be like what @Hixie said in here
#18450 (comment)
opaque just means the entire size of the gesture detector is the hit region, it doesn't stop the child from being hit. To block hits on children use an IgnorePointer or AbsorbPointer.
upd: this differs from #18450 as mine does not propose any additional explanations, but rather solely states that the current docs are wrong
reproducible sample
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(
home: Home(),
),
);
class Home extends StatelessWidget {
const Home({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
print(1);
},
child: Container(
color: Colors.red,
width: 50,
height: 50,
child: Align(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
print(2);
},
child: Container(
width: 25,
height: 25,
color: Colors.white,
),
),
),
),
),
);
}
}logs
2
2
2
2
2
2
2
2
2
2
mono0926, lchwe, MousyBusiness, jpiabrantes, yeasin50 and 1 more
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listd: api docsIssues with https://api.flutter.dev/Issues with https://api.flutter.dev/f: 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.team-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team