Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
dc38a260
Unverified
Commit
dc38a260
authored
Jan 30, 2019
by
Michael Goderbauer
Committed by
GitHub
Jan 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix asserts for initialDateTime in CupertinoDatePicker (#27272)
parent
c219e6f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
44 deletions
+27
-44
date_picker.dart
packages/flutter/lib/src/cupertino/date_picker.dart
+23
-23
date_picker_test.dart
packages/flutter/test/cupertino/date_picker_test.dart
+4
-21
No files found.
packages/flutter/lib/src/cupertino/date_picker.dart
View file @
dc38a260
...
...
@@ -168,7 +168,6 @@ class CupertinoDatePicker extends StatefulWidget {
CupertinoDatePicker
({
this
.
mode
=
CupertinoDatePickerMode
.
dateAndTime
,
@required
this
.
onDateTimeChanged
,
// ignore: always_require_non_null_named_parameters
DateTime
initialDateTime
,
this
.
minimumDate
,
this
.
maximumDate
,
...
...
@@ -179,32 +178,33 @@ class CupertinoDatePicker extends StatefulWidget {
})
:
initialDateTime
=
initialDateTime
??
DateTime
.
now
(),
assert
(
mode
!=
null
),
assert
(
onDateTimeChanged
!=
null
),
assert
(
initialDateTime
!=
null
),
assert
(
mode
!=
CupertinoDatePickerMode
.
dateAndTime
||
minimumDate
==
null
||
!
initialDateTime
.
isBefore
(
minimumDate
),
'initial date is before minimum date'
,
),
assert
(
mode
!=
CupertinoDatePickerMode
.
dateAndTime
||
maximumDate
==
null
||
!
initialDateTime
.
isAfter
(
maximumDate
),
'initial date is after maximum date'
,
),
assert
(
minimumYear
!=
null
),
assert
(
mode
!=
CupertinoDatePickerMode
.
date
||
(
minimumYear
>=
1
&&
initialDateTime
.
year
>=
minimumYear
),
'initial year is not greater than minimum year, or mininum year is not positive'
,
),
assert
(
mode
!=
CupertinoDatePickerMode
.
date
||
maximumYear
==
null
||
initialDateTime
.
year
<=
maximumYear
,
'initial year is not smaller than maximum year'
,
),
assert
(
minuteInterval
>
0
&&
60
%
minuteInterval
==
0
,
'minute interval is not a positive integer factor of 60'
,
),
assert
(
initialDateTime
.
minute
%
minuteInterval
==
0
,
'initial minute is not divisible by minute interval'
,
);
)
{
assert
(
this
.
initialDateTime
!=
null
);
assert
(
mode
!=
CupertinoDatePickerMode
.
dateAndTime
||
minimumDate
==
null
||
!
this
.
initialDateTime
.
isBefore
(
minimumDate
),
'initial date is before minimum date'
,
);
assert
(
mode
!=
CupertinoDatePickerMode
.
dateAndTime
||
maximumDate
==
null
||
!
this
.
initialDateTime
.
isAfter
(
maximumDate
),
'initial date is after maximum date'
,
);
assert
(
mode
!=
CupertinoDatePickerMode
.
date
||
(
minimumYear
>=
1
&&
this
.
initialDateTime
.
year
>=
minimumYear
),
'initial year is not greater than minimum year, or mininum year is not positive'
,
);
assert
(
mode
!=
CupertinoDatePickerMode
.
date
||
maximumYear
==
null
||
this
.
initialDateTime
.
year
<=
maximumYear
,
'initial year is not smaller than maximum year'
,
);
assert
(
this
.
initialDateTime
.
minute
%
minuteInterval
==
0
,
'initial minute is not divisible by minute interval'
,
);
}
/// The mode of the date picker as one of [CupertinoDatePickerMode].
/// Defaults to [CupertinoDatePickerMode.dateAndTime]. Cannot be null and
...
...
packages/flutter/test/cupertino/date_picker_test.dart
View file @
dc38a260
...
...
@@ -221,28 +221,11 @@ void main() {
);
});
testWidgets
(
'initial date time is not null'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
CupertinoDatePicker
(
onDateTimeChanged:
(
_
)
{},
initialDateTime:
null
,
);
},
throwsAssertionError
,
);
});
testWidgets
(
'initial date time is not null'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
CupertinoDatePicker
(
onDateTimeChanged:
(
_
)
{},
initialDateTime:
null
,
);
},
throwsAssertionError
,
testWidgets
(
'initial date is set to default value'
,
(
WidgetTester
tester
)
async
{
final
CupertinoDatePicker
picker
=
CupertinoDatePicker
(
onDateTimeChanged:
(
_
)
{},
);
expect
(
picker
.
initialDateTime
,
isNotNull
);
});
testWidgets
(
'changing initialDateTime after first build does not do anything'
,
(
WidgetTester
tester
)
async
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment