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
7b16cbcb
Unverified
Commit
7b16cbcb
authored
May 19, 2023
by
Gil Nobrega
Committed by
GitHub
May 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not animate `TabBarView` if controller is invalid (#123442)
parent
784ebdf2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+4
-0
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+62
-0
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
7b16cbcb
...
...
@@ -1893,6 +1893,10 @@ class _TabBarViewState extends State<TabBarView> {
return
false
;
}
if
(!
_controllerIsValid
)
{
return
false
;
}
_scrollUnderwayCount
+=
1
;
if
(
notification
is
ScrollUpdateNotification
&&
!
_controller
!.
indexIsChanging
)
{
final
bool
pageChanged
=
(
_pageController
.
page
!
-
_controller
!.
index
).
abs
()
>
1.0
;
...
...
packages/flutter/test/material/tabs_test.dart
View file @
7b16cbcb
...
...
@@ -3818,6 +3818,68 @@ void main() {
));
});
testWidgets
(
'TabController changes while flinging'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/34744
Widget
buildFrame
(
TabController
controller
)
{
return
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'tabs'
),
bottom:
TabBar
(
controller:
controller
,
tabs:
<
Tab
>[
const
Tab
(
text:
'A'
),
const
Tab
(
text:
'B'
),
if
(
controller
.
length
==
3
)
const
Tab
(
text:
'C'
),
],
),
),
body:
TabBarView
(
controller:
controller
,
children:
<
Widget
>[
const
Center
(
child:
Text
(
'CHILD A'
)),
const
Center
(
child:
Text
(
'CHILD B'
)),
if
(
controller
.
length
==
3
)
const
Center
(
child:
Text
(
'CHILD C'
)),
],
),
),
);
}
final
TabController
controller1
=
TabController
(
vsync:
const
TestVSync
(),
length:
2
,
);
final
TabController
controller2
=
TabController
(
vsync:
const
TestVSync
(),
length:
3
,
);
expect
(
controller1
.
index
,
0
);
expect
(
controller2
.
index
,
0
);
await
tester
.
pumpWidget
(
buildFrame
(
controller1
));
final
Offset
flingStart
=
tester
.
getCenter
(
find
.
text
(
'CHILD A'
));
await
tester
.
flingFrom
(
flingStart
,
const
Offset
(-
200.0
,
0.0
),
10000.0
);
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
// start the fling animation
controller1
.
dispose
();
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
await
tester
.
pumpWidget
(
buildFrame
(
controller2
));
// replace controller
await
tester
.
flingFrom
(
flingStart
,
const
Offset
(-
200.0
,
0.0
),
10000.0
);
await
tester
.
pumpAndSettle
();
// finish the fling animation
expect
(
controller1
.
index
,
0
);
expect
(
controller2
.
index
,
1
);
});
testWidgets
(
'TabController changes with different initialIndex'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/115917
const
Key
lastTabKey
=
Key
(
'Last Tab'
);
...
...
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