int x = 2; // explicitly typed
var p = 5; // type inferred - Generic var with type inference
dynamic z = 8; // variable can take on any type
z = "cool"; // cool
// if you never intend to change a variable use final or const. Something like this:
final email = "[[email protected]](/cdn-cgi/l/email-protection)"; // Same as var but cannot be reassigned
final String email = "[[email protected]](/cdn-cgi/l/email-protection)"; // you can't change the value
const qty = 5; // Compile-time constant
Comments