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
9fa9fd36
Unverified
Commit
9fa9fd36
authored
Oct 19, 2023
by
Kostia Sokolovskyi
Committed by
GitHub
Oct 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
_DefaultTabControllerState should dispose all created TabContoller instances. (#136608)
parent
0abb017c
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
165 additions
and
154 deletions
+165
-154
tab_controller.dart
packages/flutter/lib/src/material/tab_controller.dart
+19
-6
tabs_test.dart
packages/flutter/test/material/tabs_test.dart
+146
-148
No files found.
packages/flutter/lib/src/material/tab_controller.dart
View file @
9fa9fd36
...
...
@@ -132,8 +132,11 @@ class TabController extends ChangeNotifier {
})
:
_index
=
index
,
_previousIndex
=
previousIndex
,
_animationController
=
animationController
,
_animationDuration
=
animationDuration
;
_animationDuration
=
animationDuration
{
if
(
kFlutterMemoryAllocationsEnabled
)
{
ChangeNotifier
.
maybeDispatchObjectCreation
(
this
);
}
}
/// Creates a new [TabController] with `index`, `previousIndex`, `length`, and
/// `animationDuration` if they are non-null.
...
...
@@ -142,7 +145,10 @@ class TabController extends ChangeNotifier {
///
/// When [DefaultTabController.length] is updated, this method is called to
/// create a new [TabController] without creating a new [AnimationController].
TabController
_copyWith
({
///
/// This instance of [TabController] will be disposed and must not be used
/// anymore.
TabController
_copyWithAndDispose
({
required
int
?
index
,
required
int
?
length
,
required
int
?
previousIndex
,
...
...
@@ -151,13 +157,20 @@ class TabController extends ChangeNotifier {
if
(
index
!=
null
)
{
_animationController
!.
value
=
index
.
toDouble
();
}
return
TabController
.
_
(
final
TabController
newController
=
TabController
.
_
(
index:
index
??
_index
,
length:
length
??
this
.
length
,
animationController:
_animationController
,
previousIndex:
previousIndex
??
_previousIndex
,
animationDuration:
animationDuration
??
_animationDuration
,
);
// Nulling _animationController to not dispose it. It will be disposed by
// the newly created instance of the TabController.
_animationController
=
null
;
dispose
();
return
newController
;
}
/// An animation whose value represents the current position of the [TabBar]'s
...
...
@@ -485,7 +498,7 @@ class _DefaultTabControllerState extends State<DefaultTabController> with Single
newIndex
=
math
.
max
(
0
,
widget
.
length
-
1
);
previousIndex
=
_controller
.
index
;
}
_controller
=
_controller
.
_copyWith
(
_controller
=
_controller
.
_copyWith
AndDispose
(
length:
widget
.
length
,
animationDuration:
widget
.
animationDuration
,
index:
newIndex
,
...
...
@@ -494,7 +507,7 @@ class _DefaultTabControllerState extends State<DefaultTabController> with Single
}
if
(
oldWidget
.
animationDuration
!=
widget
.
animationDuration
)
{
_controller
=
_controller
.
_copyWith
(
_controller
=
_controller
.
_copyWith
AndDispose
(
length:
widget
.
length
,
animationDuration:
widget
.
animationDuration
,
index:
_controller
.
index
,
...
...
packages/flutter/test/material/tabs_test.dart
View file @
9fa9fd36
This diff is collapsed.
Click to expand it.
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