Skip to content

[analyzer] please make the "create constructor for final fields" fix add required where needed #45812

@sma

Description

@sma

I'm using the "create constructor for final fields" fix all the times to let my IDE generate constructors, mostly for Flutter widget but also for "normal" data classes. Unfortunately, I have manually prefix nearly all this.foo attributes with required because they are not nullable. It should be possible to detect whether I did not opt out of NNBD and generate the current syntax. Right now, the fix generates invalid code that doesn't compile.

As an additional bonus, it would be nice if the constructor would be created at the top of the class and not below the fields because according to Futter's coding style, I have to move the constructor declaration up each and every time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestdevexp-quick-fixIssues with analysis server (quick) fixeslegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions