on Saturday, 18th of July, 2020
Inferring the type
Dart is a typed language. The type of the variable
message is String. Dart can infer this
type, so you did't have to explicitly define it as a String. Importantly, this variable must be
a String forever. You cannot re-assign the variable as an integer. If you did want to create a
variable that's more dynamic, you'd use the
dynamic keyword. We'll see examples of that in a later lesson.
dynamic message = 'Hello World';
You can safely re-assign this variable to an integer.
dynamic message = 'Hello, World'; message = 8;
NB: It's rarely advisable to use
dynamic. Your code will benefit from being type safe.