- int
- double
- bool
- String
- final
- const
Types
examples/dart-intro/types.dart
add(x, y) { return x+y; } main() { var name; // null dynamic z = 1; // the same as var, not used int age; // null double o7; // null bool isit; // null String email; // null name = 'Foo'; name = 'Bar'; const address = 'New York'; //address = "Moscow"; const double pi = 3 + 0.14; final int answer = add(19, 23); print(z); // 1 z++; print(z); // 2 print(pi); // 3.14 print(answer); // 42 }
- Integers are arbitrary precision (but not in JS)
- Doubles are 64 bit
- Strings are UTF16
- Bools are true or false
Variables are either const, final, or ?? (normal?)
Both const and final can be assigned only at the time of declaration, but
final can be assigned during run-time while const can only get values that are either fixed
or can be in-lined. Such as 1+2.