Skip to content

Commit e54f2f7

Browse files
authored
Merge pull request #1 from Sasikumar3595/main
FLUT-4313-Sample updated with null safety.
2 parents d59db15 + cd4a609 commit e54f2f7

File tree

3 files changed

+33
-42
lines changed

3 files changed

+33
-42
lines changed

lib/main.dart

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,7 @@ class HeaderStyle extends StatefulWidget {
1010
}
1111

1212
class CalendarExample extends State<HeaderStyle> {
13-
DateRangePickerHeaderStyle _headerStyle;
14-
int _count;
15-
DateTime _midDate;
16-
17-
@override
18-
initState() {
19-
super.initState();
20-
}
13+
DateRangePickerHeaderStyle _headerStyle = DateRangePickerHeaderStyle();
2114

2215
Widget build(BuildContext context) {
2316
return MaterialApp(
@@ -37,15 +30,13 @@ class CalendarExample extends State<HeaderStyle> {
3730
}
3831

3932
void viewChanged(DateRangePickerViewChangedArgs viewChangedDetails) {
40-
SchedulerBinding.instance.addPostFrameCallback((duration) {
41-
_count = (viewChangedDetails.visibleDateRange.endDate
42-
.difference(viewChangedDetails.visibleDateRange.startDate)
43-
.inDays);
44-
var _middleDate = (_count ~/ 2).toInt();
45-
_midDate = viewChangedDetails.visibleDateRange.startDate
46-
.add(Duration(days: _middleDate));
33+
final DateTime startDate = viewChangedDetails.visibleDateRange.startDate!;
34+
final DateTime endDate = viewChangedDetails.visibleDateRange.endDate!;
35+
final int count = endDate.difference(startDate).inDays;
36+
final DateTime midDate = startDate.add(Duration(days: count ~/ 2));
37+
SchedulerBinding.instance!.addPostFrameCallback((duration) {
4738
setState(() {
48-
if (_midDate.month % 2 == 0) {
39+
if (midDate.month % 2 == 0) {
4940
_headerStyle = DateRangePickerHeaderStyle(
5041
textAlign: TextAlign.center,
5142
backgroundColor: Colors.lightGreen,

pubspec.lock

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ packages:
77
name: async
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "2.5.0-nullsafety.3"
10+
version: "2.5.0"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
1414
name: boolean_selector
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "2.1.0-nullsafety.3"
17+
version: "2.1.0"
1818
characters:
1919
dependency: transitive
2020
description:
2121
name: characters
2222
url: "https://pub.dartlang.org"
2323
source: hosted
24-
version: "1.1.0-nullsafety.5"
24+
version: "1.1.0"
2525
charcode:
2626
dependency: transitive
2727
description:
2828
name: charcode
2929
url: "https://pub.dartlang.org"
3030
source: hosted
31-
version: "1.2.0-nullsafety.3"
31+
version: "1.2.0"
3232
clock:
3333
dependency: transitive
3434
description:
3535
name: clock
3636
url: "https://pub.dartlang.org"
3737
source: hosted
38-
version: "1.1.0-nullsafety.3"
38+
version: "1.1.0"
3939
collection:
4040
dependency: transitive
4141
description:
4242
name: collection
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "1.15.0-nullsafety.5"
45+
version: "1.15.0"
4646
cupertino_icons:
4747
dependency: "direct main"
4848
description:
@@ -56,7 +56,7 @@ packages:
5656
name: fake_async
5757
url: "https://pub.dartlang.org"
5858
source: hosted
59-
version: "1.2.0-nullsafety.3"
59+
version: "1.2.0"
6060
flutter:
6161
dependency: "direct main"
6262
description: flutter
@@ -73,28 +73,28 @@ packages:
7373
name: intl
7474
url: "https://pub.dartlang.org"
7575
source: hosted
76-
version: "0.16.1"
76+
version: "0.17.0"
7777
matcher:
7878
dependency: transitive
7979
description:
8080
name: matcher
8181
url: "https://pub.dartlang.org"
8282
source: hosted
83-
version: "0.12.10-nullsafety.3"
83+
version: "0.12.10"
8484
meta:
8585
dependency: transitive
8686
description:
8787
name: meta
8888
url: "https://pub.dartlang.org"
8989
source: hosted
90-
version: "1.3.0-nullsafety.6"
90+
version: "1.3.0"
9191
path:
9292
dependency: transitive
9393
description:
9494
name: path
9595
url: "https://pub.dartlang.org"
9696
source: hosted
97-
version: "1.8.0-nullsafety.3"
97+
version: "1.8.0"
9898
sky_engine:
9999
dependency: transitive
100100
description: flutter
@@ -106,69 +106,69 @@ packages:
106106
name: source_span
107107
url: "https://pub.dartlang.org"
108108
source: hosted
109-
version: "1.8.0-nullsafety.4"
109+
version: "1.8.1"
110110
stack_trace:
111111
dependency: transitive
112112
description:
113113
name: stack_trace
114114
url: "https://pub.dartlang.org"
115115
source: hosted
116-
version: "1.10.0-nullsafety.6"
116+
version: "1.10.0"
117117
stream_channel:
118118
dependency: transitive
119119
description:
120120
name: stream_channel
121121
url: "https://pub.dartlang.org"
122122
source: hosted
123-
version: "2.1.0-nullsafety.3"
123+
version: "2.1.0"
124124
string_scanner:
125125
dependency: transitive
126126
description:
127127
name: string_scanner
128128
url: "https://pub.dartlang.org"
129129
source: hosted
130-
version: "1.1.0-nullsafety.3"
130+
version: "1.1.0"
131131
syncfusion_flutter_core:
132132
dependency: transitive
133133
description:
134134
name: syncfusion_flutter_core
135135
url: "https://pub.dartlang.org"
136136
source: hosted
137-
version: "18.4.41"
137+
version: "19.1.55"
138138
syncfusion_flutter_datepicker:
139139
dependency: "direct main"
140140
description:
141141
name: syncfusion_flutter_datepicker
142142
url: "https://pub.dartlang.org"
143143
source: hosted
144-
version: "18.4.41-beta"
144+
version: "19.1.55-beta"
145145
term_glyph:
146146
dependency: transitive
147147
description:
148148
name: term_glyph
149149
url: "https://pub.dartlang.org"
150150
source: hosted
151-
version: "1.2.0-nullsafety.3"
151+
version: "1.2.0"
152152
test_api:
153153
dependency: transitive
154154
description:
155155
name: test_api
156156
url: "https://pub.dartlang.org"
157157
source: hosted
158-
version: "0.2.19-nullsafety.6"
158+
version: "0.2.19"
159159
typed_data:
160160
dependency: transitive
161161
description:
162162
name: typed_data
163163
url: "https://pub.dartlang.org"
164164
source: hosted
165-
version: "1.3.0-nullsafety.5"
165+
version: "1.3.0"
166166
vector_math:
167167
dependency: transitive
168168
description:
169169
name: vector_math
170170
url: "https://pub.dartlang.org"
171171
source: hosted
172-
version: "2.1.0-nullsafety.5"
172+
version: "2.1.0"
173173
sdks:
174-
dart: ">=2.12.0-0.0 <3.0.0"
174+
dart: ">=2.12.0 <3.0.0"

pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1818
version: 1.0.0+1
1919

2020
environment:
21-
sdk: ">=2.7.0 <3.0.0"
21+
sdk: '>=2.12.0 <3.0.0'
2222

2323
dependencies:
2424
flutter:
2525
sdk: flutter
2626
# syncfusion_flutter_calendar:
2727
# path: E:\jan 20\flutter-calendar\flutter_calendar\syncfusion_flutter_calendar
28-
syncfusion_flutter_datepicker: 18.4.41-beta
29-
intl: ^0.16.1
28+
syncfusion_flutter_datepicker: ^19.1.55-beta
29+
intl: ^0.17.0
3030

3131
# The following adds the Cupertino Icons font to your application.
3232
# Use with the CupertinoIcons class for iOS style icons.
33-
cupertino_icons: ^1.0.1
33+
cupertino_icons: ^1.0.2
3434

3535
dev_dependencies:
3636
flutter_test:

0 commit comments

Comments
 (0)