Everything is null
in Dart
To check if something is null
, we can use something like
if (myVariable != null) {
// ...
}
If our variable is null
, we can assign a default value too
myVariable = myVariable ?? 0;
And we can get the null
value avoiding an error using ?
var myVariable = null;
print(myVariable?.toString());