Skip to content

Commit f918a2b

Browse files
Merge pull request #3 from Sasikumar3595/master
FLUT-4313-Sample updated with null safety.
2 parents 5ef067e + 8248912 commit f918a2b

File tree

4 files changed

+58
-164
lines changed

4 files changed

+58
-164
lines changed

README.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,21 @@
33
In the flutter date range picker, you can customize the month cells by using the `specialDates`, `blackoutDates`, and `showTrailingAndLeadingDates` properties.
44

55
## Step 1:
6-
In initState(), set the default dates for special, blackout dates, and set the default color values for the weekend days, special dates, current date, blackout dates, leading and trailing dates.
6+
Inside the state, set the default color values for the weekend days, special dates, current date, blackout dates, leading and trailing dates and initialize the special and blackout dates on initState().
77

88
```xml
9-
DateRangePickerController _controller;
10-
List<DateTime> _blackoutDates;
11-
List<DateTime> _specialDates;
12-
Color weekEndColor,
13-
specialDatesColor,
14-
todayColor,
15-
leadingTrailingDatesColor,
16-
blackoutDatesColor;
17-
9+
late List<DateTime> _blackoutDates;
10+
late List<DateTime> _specialDates;
11+
final Color weekEndColor = Color(0xFF0e9aa7),
12+
specialDatesColor = Color(0xFFf6cd61),
13+
todayColor = Color(0xFFff6f69),
14+
leadingTrailingDatesColor = Color(0xFF88d8b0),
15+
blackoutDatesColor = Colors.black;
16+
1817
@override
1918
void initState() {
20-
// TODO: implement initState
21-
_controller = DateRangePickerController();
2219
_blackoutDates = _getBlackoutDates();
2320
_specialDates = _getSpecialDates();
24-
weekEndColor = Color(0xFF0e9aa7);
25-
leadingTrailingDatesColor = Color(0xFF88d8b0);
26-
specialDatesColor = Color(0xFFf6cd61);
27-
todayColor = Color(0xFFff6f69);
28-
blackoutDatesColor = Colors.black;
2921
super.initState();
3022
}
3123
```
@@ -43,6 +35,7 @@ body: Card(
4335
specialDates: _specialDates,
4436
showTrailingAndLeadingDates: true,
4537
blackoutDates: _blackoutDates),
38+
selectionColor: Color(0xFFf8dbdff),
4639
monthCellStyle: DateRangePickerMonthCellStyle(
4740
blackoutDateTextStyle: TextStyle(
4841
color: blackoutDatesColor,
@@ -53,7 +46,6 @@ body: Card(
5346
color: specialDatesColor),
5447
specialDatesTextStyle: TextStyle(color: Colors.black),
5548
cellDecoration: BoxDecoration(shape: BoxShape.circle),
56-
selectionColor: Color(0xFFf8dbdff),
5749
todayTextStyle: TextStyle(color: Colors.white),
5850
todayCellDecoration:
5951
BoxDecoration(shape: BoxShape.circle, color: todayColor),

lib/main.dart

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,18 @@ class MonthCellCustomization extends StatefulWidget {
2323
}
2424

2525
class _MonthCellCustomizationState extends State<MonthCellCustomization> {
26-
DateRangePickerController _controller;
27-
List<DateTime> _blackoutDates;
28-
List<DateTime> _specialDates;
29-
Color weekEndColor,
30-
specialDatesColor,
31-
todayColor,
32-
leadingTrailingDatesColor,
33-
blackoutDatesColor;
26+
late List<DateTime> _blackoutDates;
27+
late List<DateTime> _specialDates;
28+
final Color weekEndColor = Color(0xFF0e9aa7),
29+
specialDatesColor = Color(0xFFf6cd61),
30+
todayColor = Color(0xFFff6f69),
31+
leadingTrailingDatesColor = Color(0xFF88d8b0),
32+
blackoutDatesColor = Colors.black;
3433

3534
@override
3635
void initState() {
37-
// TODO: implement initState
38-
_controller = DateRangePickerController();
3936
_blackoutDates = _getBlackoutDates();
4037
_specialDates = _getSpecialDates();
41-
weekEndColor = Color(0xFF0e9aa7);
42-
leadingTrailingDatesColor = Color(0xFF88d8b0);
43-
specialDatesColor = Color(0xFFf6cd61);
44-
todayColor = Color(0xFFff6f69);
45-
blackoutDatesColor = Colors.black;
4638
super.initState();
4739
}
4840

@@ -57,6 +49,7 @@ class _MonthCellCustomizationState extends State<MonthCellCustomization> {
5749
specialDates: _specialDates,
5850
showTrailingAndLeadingDates: true,
5951
blackoutDates: _blackoutDates),
52+
selectionColor: Color(0xFFf8dbdff),
6053
monthCellStyle: DateRangePickerMonthCellStyle(
6154
blackoutDateTextStyle: TextStyle(
6255
color: blackoutDatesColor,
@@ -67,7 +60,6 @@ class _MonthCellCustomizationState extends State<MonthCellCustomization> {
6760
color: specialDatesColor),
6861
specialDatesTextStyle: TextStyle(color: Colors.black),
6962
cellDecoration: BoxDecoration(shape: BoxShape.circle),
70-
selectionColor: Color(0xFFf8dbdff),
7163
todayTextStyle: TextStyle(color: Colors.white),
7264
todayCellDecoration:
7365
BoxDecoration(shape: BoxShape.circle, color: todayColor),

pubspec.lock

Lines changed: 37 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,62 @@
11
# Generated by pub
22
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
4-
archive:
5-
dependency: transitive
6-
description:
7-
name: archive
8-
url: "https://pub.dartlang.org"
9-
source: hosted
10-
version: "2.0.11"
11-
args:
12-
dependency: transitive
13-
description:
14-
name: args
15-
url: "https://pub.dartlang.org"
16-
source: hosted
17-
version: "1.5.2"
184
async:
195
dependency: transitive
206
description:
217
name: async
228
url: "https://pub.dartlang.org"
239
source: hosted
24-
version: "2.4.0"
10+
version: "2.5.0"
2511
boolean_selector:
2612
dependency: transitive
2713
description:
2814
name: boolean_selector
2915
url: "https://pub.dartlang.org"
3016
source: hosted
31-
version: "1.0.5"
32-
charcode:
17+
version: "2.1.0"
18+
characters:
3319
dependency: transitive
3420
description:
35-
name: charcode
21+
name: characters
3622
url: "https://pub.dartlang.org"
3723
source: hosted
38-
version: "1.1.2"
39-
collection:
24+
version: "1.1.0"
25+
charcode:
4026
dependency: transitive
4127
description:
42-
name: collection
28+
name: charcode
4329
url: "https://pub.dartlang.org"
4430
source: hosted
45-
version: "1.14.11"
46-
convert:
31+
version: "1.2.0"
32+
clock:
4733
dependency: transitive
4834
description:
49-
name: convert
35+
name: clock
5036
url: "https://pub.dartlang.org"
5137
source: hosted
52-
version: "2.1.1"
53-
crypto:
38+
version: "1.1.0"
39+
collection:
5440
dependency: transitive
5541
description:
56-
name: crypto
42+
name: collection
5743
url: "https://pub.dartlang.org"
5844
source: hosted
59-
version: "2.1.3"
45+
version: "1.15.0"
6046
cupertino_icons:
6147
dependency: "direct main"
6248
description:
6349
name: cupertino_icons
6450
url: "https://pub.dartlang.org"
6551
source: hosted
66-
version: "0.1.3"
52+
version: "1.0.2"
53+
fake_async:
54+
dependency: transitive
55+
description:
56+
name: fake_async
57+
url: "https://pub.dartlang.org"
58+
source: hosted
59+
version: "1.2.0"
6760
flutter:
6861
dependency: "direct main"
6962
description: flutter
@@ -74,74 +67,34 @@ packages:
7467
description: flutter
7568
source: sdk
7669
version: "0.0.0"
77-
flutter_web_plugins:
78-
dependency: transitive
79-
description: flutter
80-
source: sdk
81-
version: "0.0.0"
82-
image:
83-
dependency: transitive
84-
description:
85-
name: image
86-
url: "https://pub.dartlang.org"
87-
source: hosted
88-
version: "2.1.4"
8970
intl:
9071
dependency: transitive
9172
description:
9273
name: intl
9374
url: "https://pub.dartlang.org"
9475
source: hosted
95-
version: "0.16.1"
76+
version: "0.17.0"
9677
matcher:
9778
dependency: transitive
9879
description:
9980
name: matcher
10081
url: "https://pub.dartlang.org"
10182
source: hosted
102-
version: "0.12.6"
83+
version: "0.12.10"
10384
meta:
10485
dependency: transitive
10586
description:
10687
name: meta
10788
url: "https://pub.dartlang.org"
10889
source: hosted
109-
version: "1.1.8"
90+
version: "1.3.0"
11091
path:
11192
dependency: transitive
11293
description:
11394
name: path
11495
url: "https://pub.dartlang.org"
11596
source: hosted
116-
version: "1.6.4"
117-
pedantic:
118-
dependency: transitive
119-
description:
120-
name: pedantic
121-
url: "https://pub.dartlang.org"
122-
source: hosted
123-
version: "1.8.0+1"
124-
petitparser:
125-
dependency: transitive
126-
description:
127-
name: petitparser
128-
url: "https://pub.dartlang.org"
129-
source: hosted
130-
version: "2.4.0"
131-
plugin_platform_interface:
132-
dependency: transitive
133-
description:
134-
name: plugin_platform_interface
135-
url: "https://pub.dartlang.org"
136-
source: hosted
137-
version: "1.0.2"
138-
quiver:
139-
dependency: transitive
140-
description:
141-
name: quiver
142-
url: "https://pub.dartlang.org"
143-
source: hosted
144-
version: "2.0.5"
97+
version: "1.8.0"
14598
sky_engine:
14699
dependency: transitive
147100
description: flutter
@@ -153,112 +106,69 @@ packages:
153106
name: source_span
154107
url: "https://pub.dartlang.org"
155108
source: hosted
156-
version: "1.5.5"
109+
version: "1.8.1"
157110
stack_trace:
158111
dependency: transitive
159112
description:
160113
name: stack_trace
161114
url: "https://pub.dartlang.org"
162115
source: hosted
163-
version: "1.9.3"
116+
version: "1.10.0"
164117
stream_channel:
165118
dependency: transitive
166119
description:
167120
name: stream_channel
168121
url: "https://pub.dartlang.org"
169122
source: hosted
170-
version: "2.0.0"
123+
version: "2.1.0"
171124
string_scanner:
172125
dependency: transitive
173126
description:
174127
name: string_scanner
175128
url: "https://pub.dartlang.org"
176129
source: hosted
177-
version: "1.0.5"
130+
version: "1.1.0"
178131
syncfusion_flutter_core:
179132
dependency: transitive
180133
description:
181134
name: syncfusion_flutter_core
182135
url: "https://pub.dartlang.org"
183136
source: hosted
184-
version: "18.1.36"
137+
version: "19.1.54+1"
185138
syncfusion_flutter_datepicker:
186139
dependency: "direct main"
187140
description:
188141
name: syncfusion_flutter_datepicker
189142
url: "https://pub.dartlang.org"
190143
source: hosted
191-
version: "18.1.36-beta"
144+
version: "19.1.54-beta.1"
192145
term_glyph:
193146
dependency: transitive
194147
description:
195148
name: term_glyph
196149
url: "https://pub.dartlang.org"
197150
source: hosted
198-
version: "1.1.0"
151+
version: "1.2.0"
199152
test_api:
200153
dependency: transitive
201154
description:
202155
name: test_api
203156
url: "https://pub.dartlang.org"
204157
source: hosted
205-
version: "0.2.11"
158+
version: "0.2.19"
206159
typed_data:
207160
dependency: transitive
208161
description:
209162
name: typed_data
210163
url: "https://pub.dartlang.org"
211164
source: hosted
212-
version: "1.1.6"
213-
url_launcher:
214-
dependency: transitive
215-
description:
216-
name: url_launcher
217-
url: "https://pub.dartlang.org"
218-
source: hosted
219-
version: "5.4.2"
220-
url_launcher_macos:
221-
dependency: transitive
222-
description:
223-
name: url_launcher_macos
224-
url: "https://pub.dartlang.org"
225-
source: hosted
226-
version: "0.0.1+4"
227-
url_launcher_platform_interface:
228-
dependency: transitive
229-
description:
230-
name: url_launcher_platform_interface
231-
url: "https://pub.dartlang.org"
232-
source: hosted
233-
version: "1.0.6"
234-
url_launcher_web:
235-
dependency: transitive
236-
description:
237-
name: url_launcher_web
238-
url: "https://pub.dartlang.org"
239-
source: hosted
240-
version: "0.1.1+1"
241-
utf:
242-
dependency: transitive
243-
description:
244-
name: utf
245-
url: "https://pub.dartlang.org"
246-
source: hosted
247-
version: "0.9.0+5"
165+
version: "1.3.0"
248166
vector_math:
249167
dependency: transitive
250168
description:
251169
name: vector_math
252170
url: "https://pub.dartlang.org"
253171
source: hosted
254-
version: "2.0.8"
255-
xml:
256-
dependency: transitive
257-
description:
258-
name: xml
259-
url: "https://pub.dartlang.org"
260-
source: hosted
261-
version: "3.5.0"
172+
version: "2.1.0"
262173
sdks:
263-
dart: ">=2.5.0 <3.0.0"
264-
flutter: ">=1.12.8 <2.0.0"
174+
dart: ">=2.12.0 <3.0.0"

0 commit comments

Comments
 (0)