Practice Dart Basics & Data Types concepts
Test your understanding of Dart fundamentals including variables, data types, collections, and type conversion.
0 / 19 cleared
Practice variable declaration and immutability
Declare a variable called "name" and initialize it with your name. Then declare an uninitialized variable "age" of type int.
1// Your code hereWhat is the difference between "var" and "dynamic" in Dart?
Create a final variable "pi" with value 3.14159 and a const variable "appName" with value "MyApp".
1// Your code hereWhen should you use "late" keyword?
Declare a nullable String variable "middleName" and assign it null.
1// Your code hereWhat happens if you try to change a final variable?
Work with numeric and string data types
Create two variables: an integer "count" with value 42 and a double "price" with value 19.99.
1// Your code hereCreate a string "greeting" that says "Hello, World!" using string interpolation with two variables: greeting word and target.
1String greetingWord = "Hello";2String target = "World";3// Your code hereHow do you create a multi-line string in Dart?
Convert the string "123" to an integer and store it in a variable called "number".
1String text = "123";2// Your code hereWhat is the result of: "5" + "3" in Dart?
Round the number 3.7 to the nearest integer using the appropriate method.
1double value = 3.7;2// Your code hereMaster Lists, Sets, and Maps
Create a list of strings containing three fruit names: "Apple", "Banana", "Orange".
1// Your code hereHow do you access the first element of a list in Dart?
Add "Mango" to the fruits list and remove "Banana" from it.
1List<String> fruits = ["Apple", "Banana", "Orange"];2// Your code hereCreate a Set of integers containing: 1, 2, 3, 2, 1. What will be in the set?
1// Your code hereWhat is the main difference between List and Set?
Create a Map with String keys and int values representing ages: "Alice" -> 25, "Bob" -> 30.
1// Your code hereHow do you get a value from a Map in Dart?