0
0
Fluttermobile~10 mins

Functions and arrow syntax 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 define a function that returns the sum of two numbers using arrow syntax.

Flutter
int add(int a, int b) => [1];
Drag options to blanks, or click blank then click option'
Aa - b
Breturn a + b
Ca + b
Dprint(a + b)
Attempts:
3 left
💡 Hint
Common Mistakes
Including the 'return' keyword after the arrow.
Using subtraction instead of addition.
Using print instead of returning a value.
2fill in blank
medium

Complete the code to define a function that returns true if a number is even using arrow syntax.

Flutter
bool isEven(int number) => number [1] 2 == 0;
Drag options to blanks, or click blank then click option'
A%
B+
C*
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using division instead of modulo.
Using multiplication or addition which do not check evenness.
3fill in blank
hard

Fix the error in the arrow function that should return the length of a string.

Flutter
int getLength(String text) => [1];
Drag options to blanks, or click blank then click option'
Atext.length
Blength(text)
Ctext.length()
Dtext.size
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses like a method call.
Using non-existent properties like size.
Using a function call syntax.
4fill in blank
hard

Fill the blank to define an arrow function that returns the square of a number.

Flutter
int square(int n) => n [1] n;
Drag options to blanks, or click blank then click option'
A/
B*
C-
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or subtraction instead of multiplication.
Using division which does not square the number.
5fill in blank
hard

Fill all three blanks to create a function that returns a greeting message with a name.

Flutter
String greet(String name) => "Hello" [1] ", " [2] name [3] "!";
Drag options to blanks, or click blank then click option'
A+
B-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication operators for strings.
Forgetting to concatenate all parts.