forked from md-siam/widget_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgesturedetector.dart
53 lines (48 loc) · 1.36 KB
/
gesturedetector.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import 'package:flutter/material.dart';
class MyGestureDetector extends StatefulWidget {
const MyGestureDetector({Key? key}) : super(key: key);
@override
State<MyGestureDetector> createState() => _MyGestureDetectorState();
}
class _MyGestureDetectorState extends State<MyGestureDetector> {
int numberOfTimesTapped = 0;
// functional logic
void _increaseNumber() {
setState(() {
numberOfTimesTapped++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Gesture Detector"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'Tapped ' + numberOfTimesTapped.toString() + ' times',
style: const TextStyle(fontSize: 39),
),
GestureDetector(
onTap: _increaseNumber,
child: ClipRRect(
borderRadius: BorderRadius.circular(5),
child: Container(
padding: const EdgeInsets.all(15),
color: Colors.green[200],
child: const Text(
'TAP HERE',
style: TextStyle(fontSize: 39),
),
),
),
),
],
),
),
);
}
}