forked from md-siam/widget_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistwheelscrollview.dart
112 lines (108 loc) · 3.18 KB
/
listwheelscrollview.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
import 'package:flutter/material.dart';
import 'tile.dart';
import 'hours.dart';
import 'minutes.dart';
import 'am_pm.dart';
class MyListWheelScrollView extends StatefulWidget {
const MyListWheelScrollView({Key? key}) : super(key: key);
@override
_MyListWheelScrollViewState createState() => _MyListWheelScrollViewState();
}
class _MyListWheelScrollViewState extends State<MyListWheelScrollView> {
int currentHour = 0;
int currentMinute = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[900],
body: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// hours wheel
SizedBox(
width: 70,
child: ListWheelScrollView.useDelegate(
onSelectedItemChanged: (value) {
// do stuff
setState(() {
currentHour = value;
});
},
itemExtent: 50,
perspective: 0.005,
diameterRatio: 1.2,
physics: const FixedExtentScrollPhysics(),
childDelegate: ListWheelChildBuilderDelegate(
childCount: 13,
builder: (context, index) {
return MyHours(
hours: index,
);
},
),
),
),
const SizedBox(
width: 10,
child: Text(
':',
style: TextStyle(
color: Colors.white,
fontSize: 40,
fontWeight: FontWeight.bold),
),
),
// minutes wheel
SizedBox(
width: 70,
child: ListWheelScrollView.useDelegate(
onSelectedItemChanged: (value) {
// do stuff
setState(() {
currentMinute = value;
});
},
itemExtent: 50,
perspective: 0.005,
diameterRatio: 1.2,
physics: const FixedExtentScrollPhysics(),
childDelegate: ListWheelChildBuilderDelegate(
childCount: 60,
builder: (context, index) {
return MyMinutes(
minutes: index,
);
},
),
),
),
const SizedBox(width: 10),
// am/pm wheel
SizedBox(
width: 70,
child: ListWheelScrollView.useDelegate(
itemExtent: 50,
perspective: 0.005,
diameterRatio: 1.2,
physics: const FixedExtentScrollPhysics(),
childDelegate: ListWheelChildBuilderDelegate(
childCount: 2,
builder: (context, index) {
if (index == 0) {
return const MyAMPM(
isItAM: true,
);
} else {
return const MyAMPM(
isItAM: false,
);
}
},
),
),
),
],
),
);
}
}