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
e43850d1
Unverified
Commit
e43850d1
authored
Sep 09, 2022
by
Tom Gilder
Committed by
GitHub
Sep 09, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TabBarView with no animation not navigating (#110985)
parent
857116da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
5 deletions
+108
-5
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+6
-5
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+102
-0
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
e43850d1
...
...
@@ -1532,13 +1532,14 @@ class _TabBarViewState extends State<TabBarView> {
if
(
duration
==
Duration
.
zero
)
{
_pageController
.
jumpToPage
(
_currentIndex
!);
return
Future
<
void
>.
value
();
}
}
else
{
await
_pageController
.
animateToPage
(
_currentIndex
!,
duration:
duration
,
curve:
Curves
.
ease
);
await
_pageController
.
animateToPage
(
_currentIndex
!,
duration:
duration
,
curve:
Curves
.
ease
);
if
(!
mounted
)
{
return
Future
<
void
>.
value
();
if
(!
mounted
)
{
return
Future
<
void
>.
value
();
}
}
setState
(()
{
_warpUnderwayCount
-=
1
;
if
(
widget
.
children
!=
_children
)
{
...
...
packages/flutter/test/material/tabs_test.dart
View file @
e43850d1
...
...
@@ -1354,6 +1354,108 @@ void main() {
expect
(
position
.
pixels
,
800
);
});
testWidgets
(
'TabBarView skips animation when disabled in controller - skip tabs twice'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/110970
final
List
<
String
>
tabs
=
<
String
>[
'A'
,
'B'
,
'C'
];
final
TabController
tabController
=
TabController
(
vsync:
const
TestVSync
(),
length:
tabs
.
length
,
animationDuration:
Duration
.
zero
,
);
await
tester
.
pumpWidget
(
boilerplate
(
child:
Column
(
children:
<
Widget
>[
TabBar
(
tabs:
tabs
.
map
<
Widget
>((
String
tab
)
=>
Tab
(
text:
tab
)).
toList
(),
controller:
tabController
,
),
SizedBox
(
width:
400.0
,
height:
400.0
,
child:
TabBarView
(
controller:
tabController
,
children:
const
<
Widget
>[
Center
(
child:
Text
(
'0'
)),
Center
(
child:
Text
(
'1'
)),
Center
(
child:
Text
(
'2'
)),
],
),
),
],
),
));
expect
(
tabController
.
index
,
0
);
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
,
0
);
await
tester
.
tap
(
find
.
text
(
'C'
));
await
tester
.
pump
();
expect
(
position
.
pixels
,
800
);
await
tester
.
tap
(
find
.
text
(
'A'
));
await
tester
.
pump
();
expect
(
position
.
pixels
,
0
);
});
testWidgets
(
'TabBarView skips animation when disabled in controller - skip tabs followed by single tab navigation'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/110970
final
List
<
String
>
tabs
=
<
String
>[
'A'
,
'B'
,
'C'
];
final
TabController
tabController
=
TabController
(
vsync:
const
TestVSync
(),
length:
tabs
.
length
,
animationDuration:
Duration
.
zero
,
);
await
tester
.
pumpWidget
(
boilerplate
(
child:
Column
(
children:
<
Widget
>[
TabBar
(
tabs:
tabs
.
map
<
Widget
>((
String
tab
)
=>
Tab
(
text:
tab
)).
toList
(),
controller:
tabController
,
),
SizedBox
(
width:
400.0
,
height:
400.0
,
child:
TabBarView
(
controller:
tabController
,
children:
const
<
Widget
>[
Center
(
child:
Text
(
'0'
)),
Center
(
child:
Text
(
'1'
)),
Center
(
child:
Text
(
'2'
)),
],
),
),
],
),
));
expect
(
tabController
.
index
,
0
);
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
,
0
);
await
tester
.
tap
(
find
.
text
(
'C'
));
await
tester
.
pump
();
expect
(
position
.
pixels
,
800
);
await
tester
.
tap
(
find
.
text
(
'B'
));
await
tester
.
pump
();
expect
(
position
.
pixels
,
400
);
await
tester
.
tap
(
find
.
text
(
'A'
));
await
tester
.
pump
();
expect
(
position
.
pixels
,
0
);
});
testWidgets
(
'TabBarView skips animation when disabled in controller - two tabs'
,
(
WidgetTester
tester
)
async
{
final
List
<
String
>
tabs
=
<
String
>[
'A'
,
'B'
];
final
TabController
tabController
=
TabController
(
...
...
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