Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cillianmyles/tap-canvas
Detect taps outside the currently defined widget and provide a callback when taps occur.
https://github.com/cillianmyles/tap-canvas
callback canvas detect-taps flutter gestures library package plugin tap
Last synced: 24 days ago
JSON representation
Detect taps outside the currently defined widget and provide a callback when taps occur.
- Host: GitHub
- URL: https://github.com/cillianmyles/tap-canvas
- Owner: CillianMyles
- License: mit
- Created: 2021-02-02T19:36:19.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-11T01:12:11.000Z (over 1 year ago)
- Last Synced: 2024-03-21T18:20:35.630Z (8 months ago)
- Topics: callback, canvas, detect-taps, flutter, gestures, library, package, plugin, tap
- Language: Dart
- Homepage: https://pub.dev/packages/tap_canvas
- Size: 189 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# DEPRECATED
**_This package is no longer maintained._**
TapCanvas was originally added because Flutter did not provide a way to detect taps outside of a widget.
This has since been [added to Flutter](https://github.com/flutter/flutter/pull/107262) in the form of `TapRegion`.The core use case of TapCanvas was to dismiss focus for text fields on desktop and web, when the user tapped/clicked outside of them.
Both Material and Cupertino text fields, now provide this behaviour out of the box, which you can override if you wish to change.This package is now rendered pointless by the Flutter framework.
---
# 🚰 TapCanvas
Detect taps outside the currently defined widget and provide a callback when taps occur.
[![codecov](https://codecov.io/gh/CillianMyles/tap-canvas/branch/main/graph/badge.svg?token=B0QHI0452L)](https://codecov.io/gh/CillianMyles/tap-canvas)
[![pub package](https://img.shields.io/pub/v/tap_canvas.svg?color=success)](https://pub.dartlang.org/packages/tap_canvas)## Example
### Define the area within which you care about taps
```dart
class MyApp extends StatelessWidget {
const MyApp({super.key});@override
Widget build(BuildContext context) => MaterialApp(
home: TapCanvas(
child: MyHomeWidget(),
),
);
}
```### Now your widgets can react when the user taps outside them
```dart
class TapOutsideAwareWidget extends StatelessWidget {
const TapOutsideAwareWidget({super.key});@override
Widget build(BuildContext context) => TapOutsideDetectorWidget(
onTappedOutside: () {
print('OUTSIDE TAPPED');
},
onTappedInside: () {
print('INSIDE TAPPED');
},
child: MyWidgetThatCaresAboutTaps(),
);
}
```