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
dbfa747b
Commit
dbfa747b
authored
Apr 14, 2017
by
Hans Muller
Committed by
GitHub
Apr 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TabBarView scroll handling should factor in scroll physics tolerance (#9390)
parent
9fdd4f47
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
1 deletion
+53
-1
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+4
-1
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+49
-0
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
dbfa747b
...
...
@@ -830,7 +830,10 @@ class _TabBarViewState extends State<TabBarView> {
}
_controller
.
offset
=
(
_pageController
.
page
-
_controller
.
index
).
clamp
(-
1.0
,
1.0
);
}
else
if
(
notification
is
ScrollEndNotification
)
{
_controller
.
index
=
_pageController
.
page
.
floor
();
final
ScrollPosition
position
=
_pageController
.
position
;
final
double
pageTolerance
=
position
.
physics
.
tolerance
.
distance
/
(
position
.
viewportDimension
*
_pageController
.
viewportFraction
);
_controller
.
index
=
(
_pageController
.
page
+
pageTolerance
).
floor
();
_currentIndex
=
_controller
.
index
;
}
_warpUnderwayCount
-=
1
;
...
...
packages/flutter/test/material/tabs_test.dart
View file @
dbfa747b
...
...
@@ -759,4 +759,53 @@ void main() {
controller
.
index
=
1
;
await
tester
.
pump
(
const
Duration
(
milliseconds:
300
));
});
testWidgets
(
'TabBarView scrolls end very VERY close to a new page'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/9375
final
TabController
tabController
=
new
TabController
(
vsync:
const
TestVSync
(),
initialIndex:
1
,
length:
3
,
);
await
tester
.
pumpWidget
(
new
SizedBox
.
expand
(
child:
new
Center
(
child:
new
SizedBox
(
width:
400.0
,
height:
400.0
,
child:
new
TabBarView
(
controller:
tabController
,
children:
<
Widget
>[
const
Center
(
child:
const
Text
(
'0'
)),
const
Center
(
child:
const
Text
(
'1'
)),
const
Center
(
child:
const
Text
(
'2'
)),
],
),
),
),
),
);
expect
(
tabController
.
index
,
1
);
final
PageView
pageView
=
tester
.
widget
(
find
.
byType
(
PageView
));
final
PageController
pageController
=
pageView
.
controller
;
final
ScrollPosition
position
=
pageController
.
position
;
// The TabBarView's page width is 400, so page 0 is at scroll offset 0.0,
// page 1 is at 400.0, page 2 is at 800.0.
expect
(
position
.
pixels
,
400.0
);
// Not close enough to switch to page 2
pageController
.
jumpTo
(
800.0
-
1.25
*
position
.
physics
.
tolerance
.
distance
);
expect
(
tabController
.
index
,
1
);
// Close enough to switch to page 2
pageController
.
jumpTo
(
800.0
-
0.75
*
position
.
physics
.
tolerance
.
distance
);
expect
(
tabController
.
index
,
2
);
});
}
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