-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
closed-as-intendedClosed as the reported issue is expected behaviorClosed as the reported issue is expected behavior
Description
class Person {
final String? name;
Person([this.name]);
String printName() {
if (name != null) return name!;
return 'User';
}
}
void main() {
final a = Person();
a.printName();
}Consider this code for example. When the class is initialized since name is final, it can be determined statically that for this instance of the object the field name can't be changed anymore since its a final.
So then in the printName method, why does the analyzer require me to assert its non null
Metadata
Metadata
Assignees
Labels
closed-as-intendedClosed as the reported issue is expected behaviorClosed as the reported issue is expected behavior