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
9d2f5754
Unverified
Commit
9d2f5754
authored
Jul 19, 2022
by
NikosTsesmelis
Committed by
GitHub
Jul 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cupertino date picker fix for minDate, maxDate when using minuteInterval (#105958)
parent
784388ea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
3 deletions
+52
-3
date_picker.dart
packages/flutter/lib/src/cupertino/date_picker.dart
+5
-3
date_picker_test.dart
packages/flutter/test/cupertino/date_picker_test.dart
+47
-0
No files found.
packages/flutter/lib/src/cupertino/date_picker.dart
View file @
9d2f5754
...
...
@@ -946,11 +946,11 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
if
(
minCheck
||
maxCheck
)
{
// We have minCheck === !maxCheck.
final
DateTime
targetDate
=
minCheck
?
widget
.
minimumDate
!
:
widget
.
maximumDate
!;
_scrollToDate
(
targetDate
,
selectedDate
);
_scrollToDate
(
targetDate
,
selectedDate
,
minCheck
);
}
}
void
_scrollToDate
(
DateTime
newDate
,
DateTime
fromDate
)
{
void
_scrollToDate
(
DateTime
newDate
,
DateTime
fromDate
,
bool
minCheck
)
{
assert
(
newDate
!=
null
);
SchedulerBinding
.
instance
.
addPostFrameCallback
((
Duration
timestamp
)
{
if
(
fromDate
.
year
!=
newDate
.
year
||
fromDate
.
month
!=
newDate
.
month
||
fromDate
.
day
!=
newDate
.
day
)
{
...
...
@@ -977,7 +977,9 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
}
if
(
fromDate
.
minute
!=
newDate
.
minute
)
{
_animateColumnControllerToItem
(
minuteController
,
newDate
.
minute
);
final
double
positionDouble
=
newDate
.
minute
/
widget
.
minuteInterval
;
final
int
position
=
minCheck
?
positionDouble
.
ceil
()
:
positionDouble
.
floor
();
_animateColumnControllerToItem
(
minuteController
,
position
);
}
});
}
...
...
packages/flutter/test/cupertino/date_picker_test.dart
View file @
9d2f5754
...
...
@@ -1601,6 +1601,53 @@ void main() {
// Text style should not return unresolved color.
expect
(
paragraph
.
text
.
style
!.
color
.
toString
().
contains
(
'UNRESOLVED'
),
isFalse
);
});
testWidgets
(
'TimerPicker minDate - maxDate with minuteInterval'
,
(
WidgetTester
tester
)
async
{
late
DateTime
date
;
final
DateTime
minimum
=
DateTime
(
2022
,
6
,
14
,
3
,
31
);
final
DateTime
initial
=
DateTime
(
2022
,
6
,
14
,
3
,
40
);
final
DateTime
maximum
=
DateTime
(
2022
,
6
,
14
,
3
,
49
);
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
child:
SizedBox
(
height:
400.0
,
width:
400.0
,
child:
CupertinoDatePicker
(
initialDateTime:
initial
,
minimumDate:
minimum
,
maximumDate:
maximum
,
minuteInterval:
5
,
use24hFormat:
true
,
onDateTimeChanged:
(
DateTime
newDate
)
{
date
=
newDate
;
},
),
),
),
),
);
// Drag picker minutes to min date
await
tester
.
drag
(
find
.
text
(
'40'
),
const
Offset
(
0.0
,
32.0
),
touchSlopY:
0.0
,
warnIfMissed:
false
);
await
tester
.
pumpAndSettle
();
// Returns to min date.
expect
(
date
,
DateTime
(
2022
,
6
,
14
,
3
,
35
),
);
// Drag picker minutes to max date
await
tester
.
drag
(
find
.
text
(
'50'
),
const
Offset
(
0.0
,
-
64.0
),
touchSlopY:
0.0
,
warnIfMissed:
false
);
await
tester
.
pumpAndSettle
();
// Returns to max date.
expect
(
date
,
DateTime
(
2022
,
6
,
14
,
3
,
45
),
);
});
}
Widget
_buildPicker
(
{
...
...
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