Skip to content

Rethink required to be optional for non-nullable named parameters without default values #3206

Open
@Cat-sushi

Description

@Cat-sushi

There already have been several discussions such as #156, #878, #2050, and so on.
But, I think it is good time to rethink required to be optional.

Supporse,

class const C({/* final */ required int i});

final can be inferred by the compiler, because otherwise it is an error.
On the other hand, required is required!
I feel it weird.
Especially in context of primary constructors, terse syntax is justice.
Specify primary constructors by eernstg · Pull Request #3023 · dart-lang/language

In addition, under migration to null-safe code, {int i} had to be decided/ marked whether nullable {int? i} or required {required int i} by users.
Now, Dart 3 is fully null-safe and the migration tool has gone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureProposed language feature that solves one or more problems

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions