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
082ad114
Unverified
Commit
082ad114
authored
Jul 11, 2022
by
Bruno Leroux
Committed by
GitHub
Jul 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix TabController throws build scheduled during frame error (#105442)
parent
40fc5e86
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
6 deletions
+54
-6
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+9
-6
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+45
-0
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
082ad114
...
...
@@ -1495,15 +1495,13 @@ class _TabBarViewState extends State<TabBarView> {
}
final
Duration
duration
=
_controller
!.
animationDuration
;
if
(
duration
==
Duration
.
zero
)
{
_pageController
.
jumpToPage
(
_currentIndex
!);
return
Future
<
void
>.
value
();
}
final
int
previousIndex
=
_controller
!.
previousIndex
;
if
((
_currentIndex
!
-
previousIndex
).
abs
()
==
1
)
{
if
(
duration
==
Duration
.
zero
)
{
_pageController
.
jumpToPage
(
_currentIndex
!);
return
Future
<
void
>.
value
();
}
_warpUnderwayCount
+=
1
;
await
_pageController
.
animateToPage
(
_currentIndex
!,
duration:
duration
,
curve:
Curves
.
ease
);
_warpUnderwayCount
-=
1
;
...
...
@@ -1525,6 +1523,11 @@ class _TabBarViewState extends State<TabBarView> {
});
_pageController
.
jumpToPage
(
initialPage
);
if
(
duration
==
Duration
.
zero
)
{
_pageController
.
jumpToPage
(
_currentIndex
!);
return
Future
<
void
>.
value
();
}
await
_pageController
.
animateToPage
(
_currentIndex
!,
duration:
duration
,
curve:
Curves
.
ease
);
if
(!
mounted
)
{
return
Future
<
void
>.
value
();
...
...
packages/flutter/test/material/tabs_test.dart
View file @
082ad114
...
...
@@ -1191,6 +1191,51 @@ void main() {
expect
(
controller
.
indexIsChanging
,
false
);
});
testWidgets
(
'TabBar should not throw when animation is disabled in controller'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/102600
final
List
<
String
>
tabs
=
<
String
>[
'A'
];
Widget
buildWithTabBarView
()
{
return
boilerplate
(
child:
DefaultTabController
(
animationDuration:
Duration
.
zero
,
length:
tabs
.
length
,
child:
Column
(
children:
<
Widget
>[
TabBar
(
tabs:
tabs
.
map
<
Widget
>((
String
tab
)
=>
Tab
(
text:
tab
)).
toList
(),
isScrollable:
true
,
),
Flexible
(
child:
TabBarView
(
children:
List
<
Widget
>.
generate
(
tabs
.
length
,
(
int
index
)
=>
Text
(
'Tab
$index
'
),
),
),
),
],
),
),
);
}
await
tester
.
pumpWidget
(
buildWithTabBarView
());
TabController
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'A'
)))!;
expect
(
controller
.
index
,
0
);
tabs
.
add
(
'B'
);
await
tester
.
pumpWidget
(
buildWithTabBarView
());
tabs
.
add
(
'C'
);
await
tester
.
pumpWidget
(
buildWithTabBarView
());
await
tester
.
tap
(
find
.
text
(
'C'
));
await
tester
.
pumpAndSettle
();
controller
=
DefaultTabController
.
of
(
tester
.
element
(
find
.
text
(
'A'
)))!;
expect
(
controller
.
index
,
2
);
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'TabBarView skips animation when disabled in controller'
,
(
WidgetTester
tester
)
async
{
final
List
<
String
>
tabs
=
<
String
>[
'A'
,
'B'
,
'C'
];
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