As far as a know, checking if a object is null or Null should be the same thing on Dart.
Something like:
print(bar == null);
print(bar is Null);
should print the same value. But, in a flutter app using firebase I got the following behaviour:
print(snapshot.data['appearance']['details'].runtimeType); // Null
print(snapshot.data['appearance']['details'].runtimeType == null); // false
print(snapshot.data['appearance']['details'].runtimeType == Null); // true
print(snapshot.data['appearance']['details'].runtimeType is Null); // false
the field value is null on firebase. Why is it behaving like this?
null is a value. Null is a type.
.runtimeType returns a Type. It cannot return a null value (that would mean the object has no type). null.runtimeType returns Null; that is, the null object has a type named Null.
As for why .runtimeType is Null is false, see: What is the difference between 'is' and '==' in Dart?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With