zaagan
7/6/2019 - 4:04 AM

Dart Type Conversion

Dart Type Conversion

// String -> int
var myVal = int.parse('24');
assert(myVal == 24);

// String -> double
var piVal = double.parse('3.14');
assert(piVal == 3.14);

// int -> String
String valAsString = 55.toString();
assert(valAsString == '55');

// double -> String
String piAsString = 3.14159.toStringAsFixed(2);
assert(piAsString == '3.14');