Skip to content

When click on "Create constructor with final fields, required named", it generates syntax error #7315

Closed
@eljames

Description

@eljames

STEPS TO REPRODUCE:

  1. Create a Flutter project with Dart language
  2. Create a Dart class
  3. Create a attribute starting with underscore
  4. Mouse over on the name of attribute
  5. Click on More Options...
  6. Select the "Create constructor with final fields, required named" option
  7. The IDE will generate the constructor with syntax error: "Named parameters can't start with an underscore"

-- Possible solution

  • When click on "Create constructor with final fields, required named", it would be interesting generate like the following:
const ButtonIncrementDefault({super.key, required Widget buttonChild, required void Function() onPressed})
      : _buttonChild = buttonChild, _onPressed = onPressed;
  • Instead of:
    const ButtonIncrementDefault({super.key, required this._buttonChild, required this._onPressed});

Version info

[!] Flutter (Channel stable, 3.16.9, on Debian GNU/Linux 10 (buster) 4.19.0-25-amd64, locale pt_BR.UTF-8)
• Flutter version 3.16.9 on channel stable
! The flutter binary is not on your path. Consider adding X to your path.
! The dart binary is not on your path. Consider adding X to your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 41456452f2 (10 weeks ago), 2024-01-25 10:06:23 -0800
• Engine revision f40e976bed
• Dart version 3.2.6
• DevTools version 2.28.5
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /home/eli/Android/Sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /home/eli/installed-programs/android-studio/jbr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.

[✓] Chrome - develop for the web
• Chrome at google-chrome

[✗] Linux toolchain - develop for Linux desktop
✗ clang++ is required for Linux development.
It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/
✗ CMake is required for Linux development.
It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/
✗ ninja is required for Linux development.
It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases
• pkg-config version 0.29
✗ GTK 3.0 development libraries are required for Linux development.
They are likely available from your distribution (e.g.: apt install libgtk-3-dev)

[✓] Android Studio (version 2023.2)
• Android Studio at /home/eli/installed-programs/android-studio
• Flutter plugin version 78.4.1
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.84.1)
• VS Code at /usr/share/code
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
• Android SDK built for x86 64 (mobile) • emulator-5554 • android-x64 • Android 5.0.2 (API 21) (emulator)
• Linux (desktop) • linux • linux-x64 • Debian GNU/Linux 10 (buster) 4.19.0-25-amd64
• Chrome (web) • chrome • web-javascript • Google Chrome 121.0.6167.184

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions