Skip to content

Feature request: provide more information when an @required parameter is null #36524

Closed as not planned
@HansMuller

Description

@HansMuller

It's common for @required named parameters to be non-null.

class Foo {
  Foo({ @required this.bar }) : assert(bar != null);
  final String bar;
}

void main() {
  Foo foo = Foo();
}

Currently, upon "hot restart", this idiomatic Flutter class fails with:

E/flutter (22230): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'package:test_issue/main.dart': Failed assertion: line 4 pos 40: 'bar != null': is not true.

It would be somewhat more informative if it failed with a message like:

E/flutter (22230): 'package:test_issue/main.dart': required Foo parameter bar must not be null, line 4 pos 40

For Flutter classes it might also be helpful if a link to the API doc for the required parameter was provided.

This issue was originally reported here: flutter/flutter#29046 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-staleClosed as the issue or PR is assumed stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions