Check out example codes for "cast variable dart". It will help you in understanding the concepts better.

Code Example 1

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
}

Learn ReactJs, React Native from akashmittal.com