Python Sound Null Safety: Core Architecture
Dart features **Sound Null Safety**. By default, all types are non-nullable (`String`, `int`, `User`), meaning a variable can NEVER hold a `null` value unless explicitly annotated with a question mark (`String?`). Because the type system is 100% sound, if a variable is typed as `int`, it is guaranteed to NEVER be null at runtime, enabling ahead-of-time compiler speed optimizations.
"Sound null safety is like airport security: instead of checking passenger tickets on every step down the terminal aisle, every traveler is verified at the security gate (compile-time) so they can board the plane smoothly without repeated checks."
Deep Dive: How It Works
Non-Nullable by Default: Standard type declarations like `int count = 0;` forbid `null` assignment at compile time.
Soundness: If the compiler guarantees a variable is non-nullable, it is impossible for it to be `null` at runtime.
Optimization Unlocks: The compiler can eliminate redundant null-checks, reduce compiled binary size, and inline native machine code.
Syntax Blueprint
String nonNullable = "Always has text"; // nonNullable = null; // COMPILE ERROR! String? nullable = "Can be null"; nullable = null; // Valid
Non-nullable default vs explicit nullable declaration.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Leaving a non-nullable variable uninitialized without a default value.Why it happens: Non-nullable variables must have a valid non-null value before they can be read.
How to fix: Initialize the variable upon declaration, via constructor formals, or use `late`.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Declare Non-Nullable and Nullable Strings
Declare `String title = "Dart Course";`.
Declare `String? subtitle = null;`.
Print `Title: $title, Subtitle: $subtitle`.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.