@@ -5,27 +5,8 @@ import 'package:time_scheduler_table/src/model/event_model.dart';
5
5
import 'package:time_scheduler_table/src/widget/color_circle.dart' ;
6
6
import 'package:time_scheduler_table/src/widget/scheduler_alert.dart' ;
7
7
8
+ // ignore: must_be_immutable
8
9
class TimeSchedulerTable extends StatefulWidget {
9
- String ? title;
10
- TextStyle ? titleStyle;
11
- TextStyle ? eventTitleStyle;
12
- bool isBack;
13
- int ? currentTitleIndex;
14
- List <EventModel > eventList;
15
- double cellHeight;
16
- double cellWidth;
17
- DateTime selectedDate = DateTime .now ();
18
- ScrollController mainHorizontalController = ScrollController ();
19
- ScrollController mainVerticalController = ScrollController ();
20
- ScrollController dayHorizontalController = ScrollController ();
21
- ScrollController timeVerticalController = ScrollController ();
22
- List <int > x = [];
23
- List <int > y = [];
24
- List <String > indexList = [];
25
- List <String >? topTitles;
26
- final formKey = GlobalKey <FormState >();
27
- EventAlert eventAlert;
28
-
29
10
TimeSchedulerTable (
30
11
{super .key,
31
12
this .title,
@@ -38,24 +19,42 @@ class TimeSchedulerTable extends StatefulWidget {
38
19
required this .cellHeight,
39
20
required this .cellWidth,
40
21
required this .eventAlert});
22
+ final String ? title;
23
+ final TextStyle ? titleStyle;
24
+ final TextStyle ? eventTitleStyle;
25
+ final bool isBack;
26
+ final int ? currentTitleIndex;
27
+ final List <EventModel > eventList;
28
+ final double cellHeight;
29
+ final double cellWidth;
30
+ final selectedDate = DateTime .now ();
31
+ final ScrollController mainHorizontalController = ScrollController ();
32
+ final ScrollController mainVerticalController = ScrollController ();
33
+ final ScrollController dayHorizontalController = ScrollController ();
34
+ final ScrollController timeVerticalController = ScrollController ();
35
+ final List <int > x = [];
36
+ final List <int > y = [];
37
+ final List <String > indexList = [];
38
+ List <String >? topTitles;
39
+ final formKey = GlobalKey <FormState >();
40
+ final EventAlert eventAlert;
41
+
41
42
@override
42
43
State <TimeSchedulerTable > createState () => _TimeSchedulerTableState ();
43
44
}
44
45
45
46
class _TimeSchedulerTableState extends State <TimeSchedulerTable > {
46
47
@override
47
48
Widget build (BuildContext context) {
48
- if (widget.topTitles == null ) {
49
- widget.topTitles = ["Mon" , "Tue" , "Wed" , "Thur" , "Fri" , "Sat" , "Sun" ];
50
- }
49
+ List <String >? topTitles = widget.topTitles ?? ["Mon" , "Tue" , "Wed" , "Thur" , "Fri" , "Sat" , "Sun" ];
51
50
52
- List <Widget > headers = List .generate (widget. topTitles! .length, (index) {
51
+ List <Widget > headers = List .generate (topTitles.length, (index) {
53
52
return SizedBox (
54
53
height: 32 ,
55
54
width: widget.cellWidth,
56
55
child: Center (
57
56
child: Text (
58
- widget. topTitles! [index],
57
+ topTitles[index],
59
58
style: TextStyle (
60
59
fontWeight: FontWeight .w800,
61
60
fontSize: 10 ,
@@ -143,7 +142,6 @@ class _TimeSchedulerTableState extends State<TimeSchedulerTable> {
143
142
widget.mainVerticalController.addListener (() {
144
143
widget.timeVerticalController.jumpTo (widget.mainVerticalController.offset);
145
144
});
146
- int index = widget.eventList.length;
147
145
return Scaffold (
148
146
resizeToAvoidBottomInset: false ,
149
147
backgroundColor: Colors .grey[50 ],
@@ -209,7 +207,7 @@ class _TimeSchedulerTableState extends State<TimeSchedulerTable> {
209
207
const SizedBox (
210
208
width: 84 + 1.6 ,
211
209
),
212
- for (int i = 0 ; i < widget. topTitles! .length; i++ ) headers[i],
210
+ for (int i = 0 ; i < topTitles.length; i++ ) headers[i],
213
211
],
214
212
),
215
213
),
@@ -288,7 +286,7 @@ class _TimeSchedulerTableState extends State<TimeSchedulerTable> {
288
286
children: < Widget > [
289
287
SizedBox (
290
288
height: (18 * widget.cellHeight) + (18 * 1.6 ),
291
- width: (widget. topTitles! .length * widget.cellWidth),
289
+ width: (topTitles.length * widget.cellWidth),
292
290
child: Stack (
293
291
children: < Widget > [
294
292
Column (
@@ -299,7 +297,7 @@ class _TimeSchedulerTableState extends State<TimeSchedulerTable> {
299
297
mainAxisSize: MainAxisSize .min,
300
298
children: < Widget > [
301
299
Row (children: [
302
- for (int j = 0 ; j < widget. topTitles! .length; j++ )
300
+ for (int j = 0 ; j < topTitles.length; j++ )
303
301
GestureDetector (
304
302
onTap: () {
305
303
widget.eventAlert.alertTextController.text = "" ;
@@ -696,7 +694,7 @@ class _TimeSchedulerTableState extends State<TimeSchedulerTable> {
696
694
Row (
697
695
mainAxisSize: MainAxisSize .min,
698
696
children: < Widget > [
699
- for (var i = 0 ; i < widget. topTitles! .length; i++ )
697
+ for (var i = 0 ; i < topTitles.length; i++ )
700
698
Row (
701
699
mainAxisSize: MainAxisSize .min,
702
700
children: < Widget > [
@@ -739,7 +737,7 @@ class _TimeSchedulerTableState extends State<TimeSchedulerTable> {
739
737
}
740
738
}
741
739
742
- String ? getLessonTime (int i) {
740
+ String getLessonTime (int i) {
743
741
switch (i) {
744
742
case 0 :
745
743
return "06:00 - 07:00" ;
@@ -777,5 +775,7 @@ String? getLessonTime(int i) {
777
775
return "22:00 - 23:00" ;
778
776
case 17 :
779
777
return "23:00 - 24:00" ;
778
+ default :
779
+ return "00:00 - 00:00" ;
780
780
}
781
781
}
0 commit comments