Created with <3 with dartpad.dev.
Last active
May 1, 2023 06:19
-
-
Save timmaffett/8ced42a5d3d90fa549adb75bcfc4ef45 to your computer and use it in GitHub Desktop.
wild-gorge-8043
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith( | |
scaffoldBackgroundColor: Colors.blueGrey, | |
), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Listener( | |
behavior: HitTestBehavior.deferToChild, //<< Play with this to see different behaviors | |
onPointerDown: (details) { | |
print('OUTER onPointerDown: ${details.localPosition}'); | |
}, | |
onPointerMove: (details) { | |
print('OUTER onPointerMove: ${details.localPosition}'); | |
}, | |
// too noisy with onPointHover on outer also.. | |
//onPointerHover: (details) { | |
// print('OUTER onPointerHover: ${details.localPosition}'); | |
//}, | |
child: Column( children: | |
[ | |
Expanded( child: | |
Container( | |
color: Colors.blue, | |
child: | |
Center( | |
child: MyWidget(), | |
), | |
), | |
), | |
], | |
), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
const width = 240.0; | |
return Center( | |
child: Listener( | |
behavior: HitTestBehavior.opaque, //<< Play with this to see different behaviors | |
onPointerDown: (details) { | |
print('onPointerDown: ${details.localPosition}'); | |
}, | |
onPointerMove: (details) { | |
print('onPointerMove: ${details.localPosition}'); | |
}, | |
onPointerHover: (details) { | |
print('onPointerHover: ${details.localPosition}'); | |
}, | |
child: CircleAvatar( | |
radius: width / 2, | |
backgroundColor: Colors.black12, | |
child: Container(), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment