Skip to content

Null safety feedback: No warning for dynamic? #1324

Open
@suragch

Description

@suragch

Running the following code

void main() {
  const name = null;
  final result = greeting(name);
  print(result);
}

String greeting(String name) {
  return 'Hello $name';
}

gives the following runtime error:

type 'Null' is not a subtype of type 'String'

I suppose this is an error because of the inferred dynamic type and not with null safety itself, but it would be nice if static analysis could at least give a warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    nnbdNNBD related issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions