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
e6ed069b
Unverified
Commit
e6ed069b
authored
Feb 06, 2019
by
Michael Goderbauer
Committed by
GitHub
Feb 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix initial scroll of TabBar in release mode (#27568)
parent
ee30499a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
1 deletion
+73
-1
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+12
-1
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+61
-0
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
e6ed069b
...
...
@@ -476,10 +476,21 @@ class _TabBarScrollPosition extends ScrollPositionWithSingleContext {
final
_TabBarState
tabBar
;
bool
_initialViewportDimensionWasZero
;
@override
bool
applyContentDimensions
(
double
minScrollExtent
,
double
maxScrollExtent
)
{
bool
result
=
true
;
if
(
pixels
==
null
)
{
if
(
_initialViewportDimensionWasZero
!=
true
)
{
// If the viewport never had a non-zero dimension, we just want to jump
// to the initial scroll position to avoid strange scrolling effects in
// release mode: In release mode, the viewport temporarily may have a
// dimension of zero before the actual dimension is calculated. In that
// scenario, setting the actual dimension would cause a strange scroll
// effect without this guard because the super call below would starts a
// ballistic scroll activity.
assert
(
viewportDimension
!=
null
);
_initialViewportDimensionWasZero
=
viewportDimension
!=
0.0
;
correctPixels
(
tabBar
.
_initialScrollOffset
(
viewportDimension
,
minScrollExtent
,
maxScrollExtent
));
result
=
false
;
}
...
...
packages/flutter/test/material/tabs_test.dart
View file @
e6ed069b
...
...
@@ -2038,4 +2038,65 @@ void main() {
expect
(
find
.
text
(
AlwaysKeepAliveWidget
.
text
,
skipOffstage:
false
),
findsOneWidget
);
expect
(
find
.
text
(
'4'
),
findsOneWidget
);
});
testWidgets
(
'tabbar does not scroll when viewport dimensions initially change from zero to non-zero'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/10531.
const
List
<
Widget
>
tabs
=
<
Widget
>[
Tab
(
text:
'NEW MEXICO'
),
Tab
(
text:
'GABBA'
),
Tab
(
text:
'HEY'
),
];
final
TabController
controller
=
TabController
(
vsync:
const
TestVSync
(),
length:
tabs
.
length
);
Widget
buildTestWidget
({
double
width
,
double
height
})
{
return
MaterialApp
(
home:
Center
(
child:
SizedBox
(
height:
height
,
width:
width
,
child:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'AppBarBug'
),
bottom:
PreferredSize
(
preferredSize:
const
Size
.
fromHeight
(
30.0
),
child:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
15.0
),
child:
Align
(
alignment:
FractionalOffset
.
center
,
child:
TabBar
(
controller:
controller
,
isScrollable:
true
,
tabs:
tabs
,
),
),
),
),
),
body:
const
Center
(
child:
Text
(
'Hello World'
),
),
),
),
),
);
}
await
tester
.
pumpWidget
(
buildTestWidget
(
width:
0.0
,
height:
0.0
,
),
);
await
tester
.
pumpWidget
(
buildTestWidget
(
width:
300.0
,
height:
400.0
,
),
);
expect
(
tester
.
hasRunningAnimations
,
isFalse
);
expect
(
await
tester
.
pumpAndSettle
(),
1
);
// no more frames are scheduled.
});
}
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