Answers for "cast data type dart"

2

how to do type casting in dart for string

Casting an object to a string 
use 'as String' at the end of the expression
Posted by: Guest on September-13-2021
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
}
Posted by: Guest on October-25-2020

Code answers related to "Dart"

Browse Popular Code Answers by Language