Why does the below code give an error?
Function? fob;
void someMethod() {
if(fob != null) {
fob();
}
}
Why is this null-check not enough and fob();
here gives an error? What could be happening between the if check and the call to the function that it could be null again?
I know this works when I declare a local variable to the function, but I just want to understand why dart works the way it does.