casting in dart code example
Example 1: cast variable dart
void main() {
var foo = [1, 2.3]; // rely on inference
print(foo.runtimeType); // List<num>
var bar = foo.retype<num>();
print(bar.runtimeType); // CastList<num, num>
print(bar == foo); // false
var baz = foo.cast<num>();
print(baz.runtimeType); // List<num>
print(baz == foo); // true
}
Example 2: tyoe casting in dart
void main() {
var a = 10; // An integer.
var b = "20"; // A string.
var c = int.parse(b);
print(a + c);
}