Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/js-bhavyansh/gesturedetector
A simple Flutter app that explores how to detect and respond to different touch gestures like taps, double taps, and long presses using GestureDetector
https://github.com/js-bhavyansh/gesturedetector
flutter gesture-detector
Last synced: 2 days ago
JSON representation
A simple Flutter app that explores how to detect and respond to different touch gestures like taps, double taps, and long presses using GestureDetector
- Host: GitHub
- URL: https://github.com/js-bhavyansh/gesturedetector
- Owner: js-bhavyansh
- Created: 2024-10-19T10:28:59.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2024-10-19T16:57:38.000Z (about 1 month ago)
- Last Synced: 2024-10-23T08:18:32.182Z (28 days ago)
- Topics: flutter, gesture-detector
- Language: C++
- Homepage:
- Size: 270 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Gesture Detector Learning App
This Flutter app is built to demonstrate how to use the `GestureDetector` widget. The app increments a counter whenever the screen or a button is tapped, showcasing how gestures can be detected and responded to in Flutter.
## Features
- **Tap anywhere** on the screen to detect gestures and increase the counter.
- **Button tap** to demonstrate how to handle tap gestures on custom UI elements.
- Uses Flutter's Material 3 design system.
- Real-time display of the number of taps.## Preview
## Code Explanation
- **`MyApp` class**: The main widget of the app that sets up the theme and home page.
- **`MyHomePage` class**: A stateful widget that demonstrates how to use `GestureDetector` for detecting taps.
- **`_increaseNumber` method**: A method that increments the `numberOfTimesTapped` and updates the UI using `setState`.
- **Gesture Detectors**: There are two gesture detectors implemented—one for detecting taps anywhere on the screen and one for detecting taps on a custom button.### Main Components:
- **Scaffold**: Provides the structure for the app (body content).
- **GestureDetector**: Detects tap gestures on both the screen and a button.
- **Container**: Custom button with decoration and text that also responds to tap gestures.## GestureDetector Methods
In addition to the `onTap` method used in this app, the `GestureDetector` widget provides several other methods to detect various types of gestures. Here are some of the key methods you can explore:
- **`onDoubleTap`**: Called when the user double-taps on the widget.
- **`onLongPress`**: Called when the user presses and holds the widget for a long time.
- **`onPanUpdate`**: Called when the user drags (pans) their finger across the screen.
- **`onHorizontalDragUpdate`**: Called when the user drags their finger horizontally.
- **`onVerticalDragUpdate`**: Called when the user drags their finger vertically.
- **`onScaleUpdate`**: Called when the user pinches to zoom in or out.Each of these methods allows for customized handling of specific gestures, making `GestureDetector` a versatile widget for building interactive apps.
## Getting Started
To run this project on your local machine:
1. Clone the repository and open it in your IDE:
```bash
git clone https://github.com/Bhavyansh03-tech/FlutterTabBar.git
```
2. Run the project on an emulator or a physical device.
```bash
flutter run
```## Contributing
Contributions are welcome! Please fork the repository and submit a pull request for any improvements or bug fixes.
1. Fork the repository.
2. Create your feature branch (`git checkout -b feature/your-feature`).
3. Commit your changes (`git commit -am 'Add some feature'`).
4. Push to the branch (`git push origin feature/your-feature`).
5. Create a new Pull Request.## Contact
For questions or feedback, please contact [@Bhavyansh03-tech](https://github.com/Bhavyansh03-tech) on GitHub or connect with me on [LinkedIn](https://www.linkedin.com/in/bhavyansh03/).
---