You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (image !=null&& imageFit !=null) {
// TODO: why the ! are needed here, as check against null been performed?
The answer is, the compiler can't know if a class' filed is always null or not, because this field could be a getter that returns null sometimes and returns a value other times. You need to use the ! operator or you can copy that field to a local variable and check that variable, then the compiler knows it's not null at all.
Example:
final image =this.image;
if (image !=null&& imageFit !=null) {
// compiler knows image is not null and you don't need to use the ! operator.
The text was updated successfully, but these errors were encountered:
The painter's code have this question:
The answer is, the compiler can't know if a class' filed is always
null
or not, because this field could be a getter that returnsnull
sometimes and returns a value other times. You need to use the!
operator or you can copy that field to a local variable and check that variable, then the compiler knows it's notnull
at all.Example:
The text was updated successfully, but these errors were encountered: