tap_canvas 0.9.3 tap_canvas: ^0.9.3 copied to clipboard
Detect taps outside the currently defined widget and provide a callback when taps occur.
🚰 TapCanvas #
Detect taps outside the currently defined widget and provide a callback when taps occur.
Example #
Define the area within which you care about taps #
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => MaterialApp(
home: TapCanvas(
child: MyHomeWidget(),
),
);
}
Now your widgets can react when the user taps outside them #
class TapOutsideAwareWidget extends StatelessWidget {
const TapOutsideAwareWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => TapOutsideDetectorWidget(
onTappedOutside: () {
print('OUTSIDE TAPPED');
},
onTappedInside: () {
print('INSIDE TAPPED');
},
child: MyWidgetThatCaresAboutTaps(),
);
}