Recall & Review
beginner
What is null safety in Flutter?
Null safety means the app knows which variables can be null and which cannot, helping to avoid crashes caused by unexpected null values.
Click to reveal answer
beginner
How do you declare a variable that can hold a null value in Dart?
Add a question mark (?) after the type. For example,
String? name; means name can be null.Click to reveal answer
intermediate
What happens if you try to use a nullable variable without checking for null?
The Dart compiler will show an error, preventing you from running code that might cause a crash due to null values.
Click to reveal answer
beginner
Explain the difference between
String and String? in Dart.String cannot be null, so it always has a value. String? can be null, so you must check before using it.Click to reveal answer
intermediate
What is the purpose of the null assertion operator
! in Dart?It tells Dart you are sure the variable is not null at that point, so it can be used as a non-null value. Use carefully to avoid runtime errors.
Click to reveal answer
Which symbol marks a variable as nullable in Dart?
✗ Incorrect
The question mark (?) after a type means the variable can hold null.
What will happen if you try to assign null to a non-nullable variable?
✗ Incorrect
Dart prevents assigning null to non-nullable variables at compile time.
How do you tell Dart you are sure a nullable variable is not null?
✗ Incorrect
The null assertion operator (!) tells Dart the value is not null.
Which of these is a correct nullable variable declaration?
✗ Incorrect
The ? goes after the type to mark it nullable.
Why is null safety important in Flutter apps?
✗ Incorrect
Null safety helps avoid crashes caused by unexpected null values.
Explain how null safety helps prevent errors in Flutter apps.
Think about how the app knows if a variable can be null or not.
You got /3 concepts.
Describe how to declare and use a nullable variable safely in Dart.
Remember the question mark and null checks.
You got /3 concepts.