Variables and Data Types
Recommended Time: 2 days
This lesson will teach you everything you need to know about variables and data types in Dart. This will assist you in writing dynamic programs that can produce different results depending on the input.
The variable’s data type is defined by its value. Variables are used to store values and reserve memory space. The data-type specifies the type of value that the variable will store.
The following data types are used in Dart programming:
- Numbers
- Strings
- Booleans
- Lists
- Maps
Data types for a variable specifies the following:
- The amount of space to be allocated
- Possible values
- The operation to be performed on the variable
Dart is a programming language that is statically typed; this means that variables always have the same type, which cannot be changed. Use resources for more details about the variables and data type in dart.
Projects
1. Initialize Variables
Create a simple program that declares and initializes a few variables of different data types (such as a string, integer, and boolean), and then prints them to the console.
1. Calculate BMI
Write a program to Calculate BMI.
- Store weight in a variable
- Store height in another variable
- Calculate BMI using the formula ( weight/[height]^2 )