I'm confused why the compiler is unable to pass this without complaining:
Even if we ignore the fact that the field usage is directly following the null-check (which the compiler should be able to check?), the field is final, it can not be changed in any case. What's the problem here?
This also gives an error:
class Foo extends StatelessWidget {
const Foo({Key? key, required this.value}) : super(key: key);
final String? value;
@override
Widget build(BuildContext context) {
if(value == null) return Container();
return Text(value); // Error here, thinks this could still be null
}
}