0
0
Fluttermobile~10 mins

Variables and type inference in Flutter - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a variable with type inference holding the number 10.

Flutter
var number = [1];
Drag options to blanks, or click blank then click option'
A10.0
B"10"
Cten
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number inside quotes makes it a string, not a number.
Using a decimal number when an integer is expected.
2fill in blank
medium

Complete the code to declare a variable with type inference holding the text 'Hello'.

Flutter
var greeting = [1];
Drag options to blanks, or click blank then click option'
AHello
B"Hello"
C'Hello
Dhello
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around text makes Dart think it's a variable name.
Using mismatched or missing quotes causes errors.
3fill in blank
hard

Fix the error in the code by completing the variable declaration with type inference for a decimal number.

Flutter
var price = [1];
Drag options to blanks, or click blank then click option'
A100.5
B"100.5"
C100
Done hundred point five
Attempts:
3 left
💡 Hint
Common Mistakes
Putting decimal numbers inside quotes makes them strings.
Using words instead of numeric literals causes errors.
4fill in blank
hard

Fill both blanks to declare a variable with explicit type and assign it a boolean value.

Flutter
[1] isActive = [2];
Drag options to blanks, or click blank then click option'
Abool
Btrue
Cfalse
Dvar
Attempts:
3 left
💡 Hint
Common Mistakes
Using var when explicit type is asked.
Putting boolean values inside quotes makes them strings.
5fill in blank
hard

Fill both blanks to declare a variable with type inference, assign a list of integers, and access the first element.

Flutter
var numbers = [1];
int first = numbers[2];
print(first);;
Drag options to blanks, or click blank then click option'
A[1, 2, 3]
B[0]
C;
D[1]
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of square brackets for lists or indexing.
Forgetting the semicolon at the end of statements.