Basics
Type Inference
var lets the compiler pick the type from the initializer. Each binding still has a fixed static type, so int mixed with double widens the result to double while a quoted literal stays a String.
Program
Play the program to watch Dart infer int, double, String, and a widened total.
types_inference.dart
void main() {
var count = 3;
var price = 2.5;
var label = 'items';
var total = count * price;
print('$count $label cost $total');
}
var
`var` lets the compiler infer the type from the initializer; the binding still has a fixed static type.
inferred numeric
`3` infers `int`, `2.5` infers `double`; mixing them widens the result to `double`.
string inference
A quoted literal like `'items'` infers `String`; `var` does not mean `dynamic`.