A ? after a type marks the value as nullable. Without ?, the variable can never be null.

Program

Play the program to assign and print a nullable name.

nullable.dart
void main() {
  String? name;
  print(name);
  name = 'Ada';
  print(name);
}
String? `?` makes the variable's type nullable.
default null An uninitialized nullable starts as `null`.
non-nullable Without `?`, the compiler rejects `null` assignments.