What a problem?
In a second case, after checking value, type of variable does not changed.
// Vraible "string" still have a non-nullble type here // What problem you found here? // Non-nullble type cannot be null even only because analyzed code. print(string.length); // Don't know it's non-null here.
// This is dead code, if you don't know if (string == null) return;