Is there an existing issue for this?
Steps to reproduce
PR that marks the issue: #133759
_TabBarViewState creates a new PageController each time didChangeDependencies is called.
The previous instances of the PageController isn't disposed.
The latest instance of PageController isn't disposed in the dispose method as well.
Declaration of the PageController:
class _TabBarViewState extends State<TabBarView> {
...
late PageController _pageController;
...
|
late PageController _pageController; |
Creation of the PageController in didChangeDependencies:
...
@override
void didChangeDependencies() {
super.didChangeDependencies();
_updateTabController();
_currentIndex = _controller!.index;
_pageController = PageController(
initialPage: _currentIndex!,
viewportFraction: widget.viewportFraction,
);
}
...
|
void didChangeDependencies() { |
|
super.didChangeDependencies(); |
|
_updateTabController(); |
|
_currentIndex = _controller!.index; |
|
_pageController = PageController( |
|
initialPage: _currentIndex!, |
|
viewportFraction: widget.viewportFraction, |
|
); |
|
} |
dispose() method:
...
@override
void dispose() {
if (_controllerIsValid) {
_controller!.animation!.removeListener(_handleTabControllerAnimationTick);
}
_controller = null;
// We don't own the _controller Animation, so it's not disposed here.
super.dispose();
}
...
|
void dispose() { |
|
if (_controllerIsValid) { |
|
_controller!.animation!.removeListener(_handleTabControllerAnimationTick); |
|
} |
|
_controller = null; |
|
// We don't own the _controller Animation, so it's not disposed here. |
|
super.dispose(); |
|
} |
Expected results
All the instances of the PageController are disposed.
Actual results
All the instances of the PageController aren't disposed.
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
Flutter Doctor output
Doctor output
[✓] Flutter (Channel master, 3.14.0-12.0.pre.135, on macOS 13.0.1 22A400 darwin-arm64, locale en-GB)
• Flutter version 3.14.0-12.0.pre.135 on channel master at /Users/ksokolovskyi/dev/flutter_master
• Upstream repository [email protected]:ksokolovskyi/flutter.git
• FLUTTER_GIT_URL = [email protected]:ksokolovskyi/flutter.git
• Framework revision 5e16d2ca75 (2 hours ago), 2023-08-31 04:51:40 -0400
• Engine revision 5156c03344
• Dart version 3.2.0 (build 3.2.0-122.0.dev)
• DevTools version 2.26.2
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /Users/ksokolovskyi/Library/Android/sdk
• Platform android-33, build-tools 33.0.1
• ANDROID_HOME = /Users/ksokolovskyi/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
[✓] IntelliJ IDEA Community Edition (version 2023.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.81.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.70.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.0.1 22A400 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 116.0.5845.140
[✓] Network resources
• All expected network resources are available.
• No issues found!
Is there an existing issue for this?
Steps to reproduce
PR that marks the issue: #133759
_TabBarViewStatecreates a newPageControllereach timedidChangeDependenciesis called.The previous instances of the
PageControllerisn't disposed.The latest instance of
PageControllerisn't disposed in thedisposemethod as well.Declaration of the
PageController:flutter/packages/flutter/lib/src/material/tabs.dart
Line 1776 in 5e16d2c
Creation of the
PageControllerindidChangeDependencies:flutter/packages/flutter/lib/src/material/tabs.dart
Lines 1839 to 1847 in 5e16d2c
dispose()method:flutter/packages/flutter/lib/src/material/tabs.dart
Lines 1865 to 1872 in 5e16d2c
Expected results
All the instances of the
PageControllerare disposed.Actual results
All the instances of the
PageControlleraren't disposed.Code sample
Code sample
[Paste your code here]Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output