In my understanding a null object is an object that has no referenced value? Like a box that doesn't exist and any functions on that object are inaccessible.
Now in Null safety, more specifically Dart you can access the functions (in an extension) on a null object and get the result without having to do null checks like ? or !
void main() {
String? a;
String b;
a = "a";
b = "b";
print(a.test2);
a = null;
print(a.test2);// Here we don't need to do null checks on this object but we can still safely access "test2"
print(b.test2);
}
extension Test on String? { // Notice: The extension is on a nullable String
String get test2 => "$this test";
}
Is my understanding of null objects, null and void(Pun intended) or is there something I have missing in my understanding of null objects?
You can play around with this on https://dartpad.dev/?id=c655e00920d2078654a9277287e3e450