Skip to content

Commit 360703a

Browse files
committed
FLUT-4313-Sample updated with null safety.
1 parent 2502061 commit 360703a

File tree

4 files changed

+60
-154
lines changed

4 files changed

+60
-154
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ In the flutter date range picker, you can restrict the swiping behavior using th
66
In initState(), set the default values for min and max dates.
77

88
```xml
9-
DateTime _minDate, _maxDate;
10-
9+
late DateTime _minDate, _maxDate;
10+
1111
@override
1212
void initState() {
13-
_minDate=DateTime(2020,3, 5,9,0,0);
14-
_maxDate=DateTime(2020,3,25,9,0,0);
13+
_minDate = DateTime(2020, 3, 5, 9, 0, 0);
14+
_maxDate = DateTime(2020, 3, 25, 9, 0, 0);
1515
super.initState();
16-
}
16+
}
1717
```
1818
## Step 2:
1919
Place the date picker inside the body of the Scaffold widget with the mentioned min and max date.
@@ -56,12 +56,12 @@ class ViewRestriction extends StatefulWidget {
5656
}
5757

5858
class _ViewRestrictionState extends State<ViewRestriction> {
59-
DateTime _minDate, _maxDate;
60-
59+
late DateTime _minDate, _maxDate;
60+
6161
@override
6262
void initState() {
63-
_minDate=DateTime(2020,3, 5,9,0,0);
64-
_maxDate=DateTime(2020,3,25,9,0,0);
63+
_minDate = DateTime(2020, 3, 5, 9, 0, 0);
64+
_maxDate = DateTime(2020, 3, 25, 9, 0, 0);
6565
super.initState();
6666
}
6767

lib/main.dart

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class SwipeRestriction extends StatelessWidget {
88
@override
99
Widget build(BuildContext context) {
1010
return MaterialApp(
11-
debugShowCheckedModeBanner: false ,
11+
debugShowCheckedModeBanner: false,
1212
home: ViewRestriction(),
1313
);
1414
}
@@ -20,29 +20,25 @@ class ViewRestriction extends StatefulWidget {
2020
}
2121

2222
class _ViewRestrictionState extends State<ViewRestriction> {
23-
DateRangePickerController _controller;
24-
DateTime _minDate, _maxDate;
23+
late DateTime _minDate, _maxDate;
2524

2625
@override
2726
void initState() {
28-
// TODO: implement initState
29-
_controller = DateRangePickerController();
30-
_minDate=DateTime(2020,3, 5,9,0,0);
31-
_maxDate=DateTime(2020,3,25,9,0,0);
27+
_minDate = DateTime(2020, 3, 5, 9, 0, 0);
28+
_maxDate = DateTime(2020, 3, 25, 9, 0, 0);
3229
super.initState();
3330
}
3431

3532
@override
3633
Widget build(BuildContext context) {
3734
return Scaffold(
3835
body: Card(
39-
margin: const EdgeInsets.fromLTRB(40, 150, 40, 150),
40-
child: SfDateRangePicker(
41-
view: DateRangePickerView.month,
42-
minDate: _minDate,
43-
maxDate: _maxDate,
44-
),
45-
)
46-
);
36+
margin: const EdgeInsets.fromLTRB(40, 150, 40, 150),
37+
child: SfDateRangePicker(
38+
view: DateRangePickerView.month,
39+
minDate: _minDate,
40+
maxDate: _maxDate,
41+
),
42+
));
4743
}
4844
}

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)