Skip to content

[proposal] non-nullable named parameters required by default #878

Closed
@pedromassango

Description

@pedromassango

For example, in the code bellow I need to tell the compiler that these optional parameters are required.

  bool run({
    String taskId,
    String command,
    List<String>? args,
  }) {
    //...
  }

This code won't work in the current NNBD implementation, I need to use the required annotation.

Would be cool if the language consider every non-nullable param as required!?

So I think this:

  bool run({
    String taskId,
    String command,
    List<String>? args,
  }) {
    //...
  }

Is better than this:

  bool run({
    required String taskId,
    required String command,
    List<String>? args,
  }) {
    //...
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureProposed language feature that solves one or more problemsnnbdNNBD related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions