Basics
Comments and Scope
A // comment is reader-only text that Dart skips at runtime. Each { ... } block introduces a new scope: a var declared inside disappears at the closing brace, while names from the enclosing scope stay visible.
Program
Play the program to enter an if block, build a label from inner state, then watch that inner name go out of scope.
comments_scope.dart
void main() {
var label = 'outer';
// a reader-only comment; this does not run
if (label == 'outer') {
var detail = 'inner';
label = '$label/$detail';
}
print(label);
}
// comment
Lines starting with `//` are for readers only; Dart skips them at runtime.
block scope
`var detail` declared inside the `{ ... }` block exists only there; the outer `label` stays visible.
after the brace
Past the closing `}` `detail` is gone, but `label` keeps its updated value.