Skip to content

Instantly share code, notes, and snippets.

@shihaohong
Last active March 20, 2020 21:49
Show Gist options
  • Save shihaohong/31c9d7394f02595a04ff45b587aee23c to your computer and use it in GitHub Desktop.
Save shihaohong/31c9d7394f02595a04ff45b587aee23c to your computer and use it in GitHub Desktop.
tapdown magic
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark(),
home: Scaffold(
appBar: AppBar(title: const Text('Tapdown')),
body: GestureDetector(
onTap: () => print('tap down bottom'),
child: Container(
color: Colors.blue.withOpacity(0.8),
child: Center(
child: Container(
width: 100,
height: 100,
color: Colors.green.withOpacity(0.8),
child: GestureDetector(
behavior: HitTestBehavior.deferToChild,
onTap: () => print('tap down top'),
child: Center(
child: Container(
width: 50,
height: 50,
color: Colors.yellow,
),
),
),
),
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment