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
8b889d35
Unverified
Commit
8b889d35
authored
Mar 11, 2021
by
Michael Debertol
Committed by
GitHub
Mar 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DatePicker] Don't jump to the current month (#77739)
parent
aaa7f842
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
calendar_date_picker.dart
packages/flutter/lib/src/material/calendar_date_picker.dart
+1
-1
calendar_date_picker_test.dart
...ages/flutter/test/material/calendar_date_picker_test.dart
+20
-0
No files found.
packages/flutter/lib/src/material/calendar_date_picker.dart
View file @
8b889d35
...
@@ -531,7 +531,7 @@ class _MonthPickerState extends State<_MonthPicker> {
...
@@ -531,7 +531,7 @@ class _MonthPickerState extends State<_MonthPicker> {
@override
@override
void
didUpdateWidget
(
_MonthPicker
oldWidget
)
{
void
didUpdateWidget
(
_MonthPicker
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
super
.
didUpdateWidget
(
oldWidget
);
if
(
widget
.
initialMonth
!=
oldWidget
.
initialMonth
)
{
if
(
widget
.
initialMonth
!=
oldWidget
.
initialMonth
&&
widget
.
initialMonth
!=
_currentMonth
)
{
// We can't interrupt this widget build with a scroll, so do it next frame
// We can't interrupt this widget build with a scroll, so do it next frame
WidgetsBinding
.
instance
!.
addPostFrameCallback
(
WidgetsBinding
.
instance
!.
addPostFrameCallback
(
(
Duration
timeStamp
)
=>
_showMonth
(
widget
.
initialMonth
,
jump:
true
)
(
Duration
timeStamp
)
=>
_showMonth
(
widget
.
initialMonth
,
jump:
true
)
...
...
packages/flutter/test/material/calendar_date_picker_test.dart
View file @
8b889d35
...
@@ -431,6 +431,26 @@ void main() {
...
@@ -431,6 +431,26 @@ void main() {
expect
(
find
.
text
(
'2016'
),
findsNothing
);
// 2016 in year grid
expect
(
find
.
text
(
'2016'
),
findsNothing
);
// 2016 in year grid
});
});
testWidgets
(
'Dragging more than half the width should not cause a jump'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
calendarDatePicker
());
await
tester
.
pumpAndSettle
();
final
TestGesture
gesture
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byType
(
PageView
)));
// This initial drag is required for the PageView to recognize the gesture, as it uses DragStartBehavior.start.
// It does not count towards the drag distance.
await
gesture
.
moveBy
(
const
Offset
(
100
,
0
));
// Dragging for a bit less than half the width should reveal the previous month.
await
gesture
.
moveBy
(
const
Offset
(
800
/
2
-
1
,
0
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'January 2016'
),
findsOneWidget
);
expect
(
find
.
text
(
'1'
),
findsNWidgets
(
2
));
// Dragging a bit over the half should still show both.
await
gesture
.
moveBy
(
const
Offset
(
2
,
0
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'December 2015'
),
findsOneWidget
);
expect
(
find
.
text
(
'1'
),
findsNWidgets
(
2
));
});
group
(
'Keyboard navigation'
,
()
{
group
(
'Keyboard navigation'
,
()
{
testWidgets
(
'Can toggle to year mode'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Can toggle to year mode'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
calendarDatePicker
());
await
tester
.
pumpWidget
(
calendarDatePicker
());
...
...
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