Basics
Dynamic and Object
Object is Dart's safe top type: any non-null value fits, but only Object members are callable without a cast. dynamic opts out of static checking, so members and reassignments are accepted at compile time and resolved at runtime.
Program
Play the program to hold a String as Object, do arithmetic on a dynamic int, and print both.
dynamic_object.dart
void main() {
Object boxed = 'Ada';
dynamic flexible = 3;
flexible = flexible + 2;
var label = boxed.toString();
print('$label $flexible');
}
Object top type
`Object boxed = 'Ada'` keeps the value safe; only `Object` members like `toString()` are callable without a cast.
dynamic
`dynamic flexible = 3` skips static checks; `flexible + 2` is resolved at runtime against the underlying `int`.
rebind
A `dynamic` binding can be reassigned to anything; here the value moves from `3` to `5` and stays an `int`.