Complete the code to declare a variable that cannot be changed.
final [1] = 10;
The keyword final declares a variable that cannot be changed after it is set. You need to provide a variable name, like count.
Complete the code to define a function that returns a greeting string.
String greet() {
return [1];
}The function returns a string literal. In Dart, string literals can be in single quotes '...' or double quotes "...". Here, single quotes are used.
Fix the error in the code to create a list of integers.
List<int> numbers = [1];In Dart, lists are created using square brackets []. Parentheses () are for tuples (not in Dart), curly braces {} are for sets or maps, and angle brackets <> are for generics.
Fill both blanks to create a map with string keys and integer values.
Map<String, int> ages = [1]; ages['Alice'] = [2];
The map is created with curly braces and key-value pairs. To add or update a value, use the key in brackets and assign an integer.
Fill all three blanks to create a conditional that prints a message if a number is positive.
int number = 5; if (number [1] 0) { print([2]); } else { print([3]); }
The condition checks if the number is greater than zero. If true, it prints 'Positive', otherwise 'Not positive'.