-
Notifications
You must be signed in to change notification settings - Fork 1
/
eye_modeling.dart
114 lines (101 loc) · 2.84 KB
/
eye_modeling.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import 'package:flutter/material.dart';
class EyeAnimationTestScreen extends StatefulWidget {
const EyeAnimationTestScreen({super.key});
@override
// ignore: library_private_types_in_public_api
_EyeAppState createState() => _EyeAppState();
}
class _EyeAppState extends State<EyeAnimationTestScreen> {
bool isEyeClosed = false;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: GestureDetector(
onTap: () {
setState(() {
isEyeClosed = !isEyeClosed;
});
},
onPanUpdate: (details) {
setState(() {
isEyeClosed = true;
});
},
onPanEnd: (details) {
setState(() {
isEyeClosed = false;
});
},
child: EyeWidget(isClosed: isEyeClosed),
),
),
);
}
}
class EyeWidget extends StatelessWidget {
final bool isClosed;
const EyeWidget({Key? key, required this.isClosed}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
width: 200,
height: 200,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: const RadialGradient(
colors: [
Colors.red,
Colors.black,
],
stops: [0.4, 1.0],
),
border: Border.all(color: Colors.black, width: 2.0),
),
child: Center(
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
width: isClosed ? 50 : 80,
height: isClosed ? 50 : 80,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
),
),
);
}
}
// class EyeWidget extends StatelessWidget {
// final bool isClosed;
// const EyeWidget({Key? key, required this.isClosed}) : super(key: key);
// @override
// Widget build(BuildContext context) {
// return Container(
// width: 200,
// height: 200,
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// gradient: RadialGradient(
// colors: [
// Colors.purple,
// Colors.black,
// ],
// stops: [0.4, 1.0],
// ),
// border: Border.all(color: Colors.black, width: 2.0),
// ),
// child: Center(
// child: AnimatedContainer(
// duration: const Duration(milliseconds: 300),
// width: isClosed ? 50 : 80,
// height: isClosed ? 50 : 80,
// decoration: const BoxDecoration(
// shape: BoxShape.circle,
// color: Colors.black,
// ),
// ),
// ),
// );
// }
// }