Closed
Description
Hello,
The issue is illustrated in this code snippet:
class Foo {
String? _string;
Foo() : _string = '';
String doSomething() {
return _string==null ? '' : _string; // => ERROR: A value of type String? cannot be returned...
}
String doSomething2(String? string) {
return string==null ? '' : string;
}
}
In doSomething(), the compiler issues an error: 'A value of type String? cannot be returned from method 'doSomething' because if has return type of String.
I don't understand why, because I have handled nullity with the test.
In addition, the same example is working if I get the input String? as parameter, and do not use the member (see doSomething2())
I have Dart 2.12.0-29.10.beta.
Metadata
Metadata
Assignees
Labels
No labels