Skip to content

Arrow onError functions causes type failure #31928

Closed
@grouma

Description

@grouma

The following will give a type error:

void showError() { ... }

SomeType someMethod(){
     return foo.bar().first.then((blah)=>blah, onError: (error) => showError());
}

This is because showError returns void when SomeType is expected.

To fix one simply needs to do remove the fat arrow:

void showError() { ... }

SomeType someMethod(){
     return foo.bar().first.then((blah)=>blah, onError: (error) { showError();});
}

This is a pain and the void return type of showError should be interpreted as returning null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions