Skip to content

Bind all parameters to fields appears twice, mangles up code and places caret at wrong position #62201

@denniskaselow

Description

@denniskaselow

Using Dart SDK version: 3.11.0-190.0.dev (dev) (Mon Dec 1 04:03:43 2025 -0800) on "windows_x64"

The following code:

class Foo {
  Foo({required int foo, required int foobar});
}

shows two assists, both named "Bind all parameters to fields". with the second one only binding one parameter to a field.
Image

But it looks like an assist with a correct text ("Bind parameter to field") exists:

static const bindAllToFields = AssistKind(
'dart.assist.bindAllToFields',
DartAssistKindPriority.default_,
'Bind all parameters to fields',
);
static const bindToField = AssistKind(
'dart.assist.bindToField',
DartAssistKindPriority.default_,
'Bind parameter to field',
);

Furthermore, selecting the second assist on foo, creates this:

Image

The placeholder-thingies where I can enter a different type or name are misplaced.

If I select the first "Bind all parameters to fields" assist, it creates this abomination:

class Foo {
  Foo({required this.foo, required this.bar});

is.nar}oo;

  int bar;
}

More parameters create a greater mess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions