@@ -12,16 +12,15 @@ class AppointmentWithoutWeekends extends StatefulWidget {
1212}
1313
1414class CalendarAppointment extends State <AppointmentWithoutWeekends > {
15- CalendarDataSource _dataSource;
16- List <String > _subjectCollection;
17- List <DateTime > _startTimeCollection, _endTimeCollection;
18- List <Color > _colorCollection;
19- List <TimeRegion > _specialTimeRegion;
15+ final CalendarDataSource _dataSource = _DataSource (< Appointment > []);
16+ final List <String > _subjectCollection = < String > [];
17+ final List <DateTime > _startTimeCollection = < DateTime > [];
18+ final List <DateTime > _endTimeCollection = < DateTime > [];
19+ final List <Color > _colorCollection = < Color > [];
20+ List <TimeRegion > _specialTimeRegion = < TimeRegion > [];
2021
2122 @override
2223 void initState () {
23- _dataSource = _DataSource (< Appointment > []);
24- _specialTimeRegion= < TimeRegion > [];
2524 _getSubjectCollection ();
2625 _getStartTimeCollection ();
2726 _getEndTimeCollection ();
@@ -59,9 +58,9 @@ class CalendarAppointment extends State<AppointmentWithoutWeekends> {
5958
6059 void viewChanged (ViewChangedDetails viewChangedDetails) {
6160 List <DateTime > visibleDates = viewChangedDetails.visibleDates;
62- List <TimeRegion > _timeRegion = < TimeRegion > [];
61+ List <TimeRegion > _timeRegion = < TimeRegion > [];
6362 List <Appointment > appointments = < Appointment > [];
64- _dataSource.appointments.clear ();
63+ _dataSource.appointments! .clear ();
6564
6665 for (int i = 0 ; i < visibleDates.length; i++ ) {
6766 if (visibleDates[i].weekday == 6 || visibleDates[i].weekday == 7 ) {
@@ -71,8 +70,10 @@ class CalendarAppointment extends State<AppointmentWithoutWeekends> {
7170 startTime: DateTime (visibleDates[i].year, visibleDates[i].month,
7271 visibleDates[i].day, 13 , 0 , 0 ),
7372 endTime: DateTime (visibleDates[i].year, visibleDates[i].month,
74- visibleDates[i].day, 14 , 0 , 0 ),text: 'Break' ,enablePointerInteraction: false ));
75- SchedulerBinding .instance.addPostFrameCallback ((timeStamp) {
73+ visibleDates[i].day, 14 , 0 , 0 ),
74+ text: 'Break' ,
75+ enablePointerInteraction: false ));
76+ SchedulerBinding .instance! .addPostFrameCallback ((timeStamp) {
7677 setState (() {
7778 _specialTimeRegion = _timeRegion;
7879 });
@@ -101,14 +102,13 @@ class CalendarAppointment extends State<AppointmentWithoutWeekends> {
101102 }
102103 }
103104 for (int i = 0 ; i < appointments.length; i++ ) {
104- _dataSource.appointments.add (appointments[i]);
105+ _dataSource.appointments! .add (appointments[i]);
105106 }
106107 _dataSource.notifyListeners (
107- CalendarDataSourceAction .reset, _dataSource.appointments);
108+ CalendarDataSourceAction .reset, _dataSource.appointments! );
108109 }
109110
110111 void _getSubjectCollection () {
111- _subjectCollection = < String > [];
112112 _subjectCollection.add ('General Meeting' );
113113 _subjectCollection.add ('Plan Execution' );
114114 _subjectCollection.add ('Project Plan' );
@@ -122,7 +122,6 @@ class CalendarAppointment extends State<AppointmentWithoutWeekends> {
122122 }
123123
124124 void _getStartTimeCollection () {
125- _startTimeCollection = < DateTime > [];
126125 var currentDateTime = DateTime .now ();
127126
128127 _startTimeCollection.add (new DateTime (currentDateTime.year,
@@ -143,11 +142,9 @@ class CalendarAppointment extends State<AppointmentWithoutWeekends> {
143142 currentDateTime.month, currentDateTime.day, 17 , 0 , 0 ));
144143 _startTimeCollection.add (new DateTime (currentDateTime.year,
145144 currentDateTime.month, currentDateTime.day, 18 , 0 , 0 ));
146-
147145 }
148146
149147 void _getEndTimeCollection () {
150- _endTimeCollection = < DateTime > [];
151148 var currentDateTime = DateTime .now ();
152149 _endTimeCollection.add (new DateTime (currentDateTime.year,
153150 currentDateTime.month, currentDateTime.day, 10 , 0 , 0 ));
@@ -170,7 +167,6 @@ class CalendarAppointment extends State<AppointmentWithoutWeekends> {
170167 }
171168
172169 void _getColorCollection () {
173- _colorCollection = < Color > [];
174170 _colorCollection.add (const Color (0xFF0F8644 ));
175171 _colorCollection.add (const Color (0xFF8B1FA9 ));
176172 _colorCollection.add (const Color (0xFFD20100 ));
0 commit comments