Skip to content

dart fix - Add the ability to replace a static method invocation with a const constructor. #49056

@darrenaustin

Description

@darrenaustin

The Flutter team has a static function on MaterialStateProperty:

static MaterialStateProperty<T> all<T>(T value)

We would like to have a dart fix that will allow us to replace invocations of .all with a call to a constructor for a new class that implements MaterialStateProperty<T>:

const MaterialStatePropertyAll(this.value);

So instead of:

final color = MaterialStateProperty<Color>.all(Colors.blue);

We want:

const color MaterialStatePropertyAll<Color>(Colors.blue);

Looking at the docs for fixes, there doesn't appear to be a way to define this kind of transform. If possible this would be a nice feature for us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions