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
234855ca
Unverified
Commit
234855ca
authored
Dec 11, 2018
by
Hans Muller
Committed by
GitHub
Dec 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle a TabBarView special case: last tab deleted before animation ends (#24892)
parent
3cca1a2e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
2 deletions
+54
-2
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+3
-2
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+51
-0
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
234855ca
...
...
@@ -1168,9 +1168,10 @@ class _TabBarViewState extends State<TabBarView> {
if
(
notification
is
ScrollUpdateNotification
&&
!
_controller
.
indexIsChanging
)
{
if
((
_pageController
.
page
-
_controller
.
index
).
abs
()
>
1.0
)
{
_controller
.
index
=
_pageController
.
page
.
floor
();
_currentIndex
=
_controller
.
index
;
_currentIndex
=
_controller
.
index
;
}
_controller
.
offset
=
(
_pageController
.
page
-
_controller
.
index
).
clamp
(-
1.0
,
1.0
);
if
(
_controller
.
length
>
1
)
_controller
.
offset
=
(
_pageController
.
page
-
_controller
.
index
).
clamp
(-
1.0
,
1.0
);
}
else
if
(
notification
is
ScrollEndNotification
)
{
_controller
.
index
=
_pageController
.
page
.
round
();
_currentIndex
=
_controller
.
index
;
...
...
packages/flutter/test/material/tabs_test.dart
View file @
234855ca
...
...
@@ -1895,4 +1895,55 @@ void main() {
expect
(
find
.
text
(
AlwaysKeepAliveWidget
.
text
,
skipOffstage:
false
),
findsOneWidget
);
expect
(
find
.
text
(
'4'
),
findsOneWidget
);
});
testWidgets
(
'Removing the last tab'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/24424
final
List
<
Tab
>
tabs
=
<
Tab
>[
const
Tab
(
text:
'LEFT'
),
const
Tab
(
text:
'RIGHT'
)];
Widget
buildFrame
(
TabController
controller
)
{
return
boilerplate
(
child:
Container
(
alignment:
Alignment
.
topLeft
,
child:
Column
(
children:
<
Widget
>[
TabBar
(
controller:
controller
,
tabs:
tabs
),
Expanded
(
child:
TabBarView
(
controller:
controller
,
children:
tabs
)),
]
),
),
);
}
final
TabController
controller1
=
TabController
(
vsync:
const
TestVSync
(),
length:
2
,
initialIndex:
0
,
);
await
tester
.
pumpWidget
(
buildFrame
(
controller1
));
expect
(
controller1
.
index
,
0
);
await
tester
.
tap
(
find
.
text
(
'RIGHT'
));
expect
(
controller1
.
index
,
1
);
expect
(
controller1
.
indexIsChanging
,
true
);
// At this point the change selected tab animation hasn't completed.
// When the controller is replaced the TabBarView will see one last
// scroll notification. Since there's only one tab left, it can be
// ignored.
final
TabController
controller2
=
TabController
(
vsync:
const
TestVSync
(),
length:
1
,
initialIndex:
0
,
);
tabs
.
removeAt
(
1
);
await
tester
.
pumpWidget
(
buildFrame
(
controller2
));
await
tester
.
pumpAndSettle
();
expect
(
controller1
.
indexIsChanging
,
false
);
expect
(
controller2
.
index
,
0
);
});
}
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