Closed
Description
Describe the bug
When using the code snippet to create a Flutter Widget with Animation Controller
,
the implementation in void dispose()
is wrong.
The documentation for void dispose()
states:
Implementations of this method should end with a call to the inherited method, as in super.dispose().
but the snippet generates
class _SomeWidget extends StatefulWidget {
const_SomeWidget({Key? key}) : super(key: key);
@override
State<_SomeWidget> createState() => _SomeWidgetState();
}
class _SomeWidgetState extends State<_SomeWidget>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this);
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
@override
Widget build(BuildContext context) {
return Container();
}
}
To Reproduce
Steps to reproduce the behavior:
- Create a new Flutter project
- Open
main.dart
- Use the snippet
Flutter Widget with AnimationController
Expected behavior
The snippet should have generated
@override
void dispose(){
_controller.dispose();
super.dispose();
}
Screenshots
N/A
Please complete the following information:
- Operating System and version: MacOS 12.2.1 (21D62)
- VS Code version: 1.67.1
- Dart extension version: v3.40.0
- Dart/Flutter SDK version:
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-x64, locale en-BE)
• Flutter version 2.10.3 at /Users/navaronbracke/Documents/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (3 months ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/navaronbracke/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• ANDROID_HOME = /Users/navaronbracke/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• 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 11.0.11+0-b60-7590822)
[✓] VS Code (version 1.67.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.40.0
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 101.0.4951.64
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!