Recall & Review
beginner
What is a variable in Flutter?
A variable is a name that holds a value. It can store data like numbers, text, or objects that your app uses.
Click to reveal answer
beginner
How does type inference work in Flutter?
Type inference means Flutter can guess the type of a variable from the value you assign, so you don't always need to write the type explicitly.
Click to reveal answer
beginner
What keyword do you use in Flutter for a variable whose type is inferred?
You use the keyword
var to declare a variable with type inference.Click to reveal answer
intermediate
Can you change the type of a variable declared with
var later?No, once a variable is assigned a type by inference, you cannot assign a value of a different type to it later.
Click to reveal answer
intermediate
What is the difference between
var and dynamic in Flutter?var infers the type and keeps it fixed, while dynamic allows the variable to hold any type and can change at runtime.Click to reveal answer
Which keyword lets Flutter guess the variable type automatically?
✗ Incorrect
The var keyword tells Flutter to infer the type from the assigned value.
What happens if you assign a string to a
var variable initially holding an int?✗ Incorrect
Flutter fixes the type at the first assignment, so assigning a different type later causes a type error.
Which keyword allows a variable to hold any type and change it later?
✗ Incorrect
dynamic allows the variable to hold any type and change it at runtime.
What is the type of a variable declared as
var name = 'Alice';?✗ Incorrect
Flutter infers the type String because the value is text.
Which keyword declares a variable that cannot be changed after it is set?
✗ Incorrect
final declares a variable that can only be set once and then cannot change.
Explain how Flutter uses type inference with the
var keyword.Think about how Flutter decides the variable's type without you writing it.
You got /3 concepts.
Describe the difference between
var and dynamic variables in Flutter.Consider how flexible each variable type is after declaration.
You got /3 concepts.