Skip to content

Put the TODO comment after the super function call in the autocompletion for inherited methods where the Flutter documentation says that the inherited method should be called at the start #61710

@TB-StarcMed

Description

@TB-StarcMed

When using the autocomplete functionality for overriding the function initState of a class that is extending class State, then Visual Studio Code adds the following code:

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

I started using Flutter in January this year. Since I had not looked at the documentation for the initState function after completing the Flutter tutorial and working a while with Flutter, I did not know that the documentation for the initState function says that "Implementations of this method should start with a call to the inherited method, as in super.initState()" and assumed that I just need to replace the TODO comment with the code that I need. However, when I read this by just wanting to read what the initState function does, I learned that the custom code should come after the parent's function is called and I then changed all overrides of the initState function such that the parent function is called at the start.

With this "mishap" in mind, I want to suggest a change of the autocomplete functionality that for functions where the documentation recommends that the parent function should be called at the start that there the TODO comment is placed after the parent function call, like so:

  @override
  void initState() {
    super.initState();
    // TODO: implement initState
  }

The following is my Flutter doctor -v output:

[√] Flutter (Channel stable, 3.32.8, on Microsoft Windows [Version 10.0.26100.6584], locale de-DE) [311ms]
    • Flutter version 3.32.8 on channel stable at C:\Progs\Flutter\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision edada7c56e (3 months ago), 2025-07-25 14:08:03 +0000
    • Engine revision ef0cd00091
    • Dart version 3.8.1
    • DevTools version 2.45.1

[√] Windows Version (Windows 11 or higher, 24H2, 2009) [775ms]

[√] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [4,0s]
    • Android SDK at C:\Progs\Android_SDK
    • Platform android-36.1, build-tools 36.1.0
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.7+-13880790-b1038.58)
    • All Android licenses accepted.

[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.14.16) [92ms]
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
    • Visual Studio Build Tools 2022 version 17.14.36518.9
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2025.1.3) [10ms]
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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 21.0.7+-13880790-b1038.58)

[√] VS Code, 64-bit edition (version 1.104.3) [9ms]
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.120.0

[√] Connected device (1 available) [89ms]
    • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.26100.6584]

[√] Network resources [228ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-pkg-metaIssues related to package:meta

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions