Dart Fundamentals interview question · Most asked
What is sound null safety in Dart?
Summary
Types are non-nullable by default; T? allows null. The compiler forces null checks before using nullable values and guarantees non-nullable variables never hold null at runtime.
Longer Answer
Use ?., ?? and ??=, rely on type promotion after checks, and keep the ! operator and late for rare cases.
Key Points
- Non-nullable by default.
- Flow analysis promotes after checks.
- ! and late can still fail at runtime.
Deep dive: Dart Fundamentals: Null Safety