const name = “ ”
A strongly Typed language has you write a variable like this:
const String name = “ ”
We declare that this variable is a string data type, and so the program knows that if anything other than a string is stored in that variable, it won't allow it. The system checks at compile time and will error out. This helps to cut down on errors immensely and keeps the app running more smoothly.
Data types in Dart are pretty standard, but understanding how to write them correctly can take practice. Here is the list of Dart’s data types and how to write them when declaring a variable.
Strings variables act the same in Dart as other languages, they store characters — letters, numbers, and special characters — in a variable declared with the String keyword. They are represented with either single or double quotes in Dart.
Integers come in a couple of different flavors with Dart. Depending on if the data will be a whole number or a decimal, you would use “int” for a whole number and the “double” keyword for a decimal. Or it can be declared using “num” to accept both whole numbers or decimals.
Booleans variables are used to store true or false values. The value is stored as either true or false. The keyword bool is placed before a boolean variable.