Answers for "string to int in dart, string to double in dart, int to string in dart"

0

string to int in dart, string to double in dart, int to string in dart

// String -> int
var one = int.parse('1');
assert(one == 1);

// String -> double
var onePointOne = double.parse('1.1');
assert(onePointOne == 1.1);

// int -> String
String oneAsString = 1.toString();
assert(oneAsString == '1');

// double -> String
String piAsString = 3.14159.toStringAsFixed(2);
assert(piAsString == '3.14');
Posted by: Guest on April-14-2022
0

string to int in dart, string to double in dart, int to string in dart

// String -> int
var one = int.parse('1');
assert(one == 1);

// String -> double
var onePointOne = double.parse('1.1');
assert(onePointOne == 1.1);

// int -> String
String oneAsString = 1.toString();
assert(oneAsString == '1');

// double -> String
String piAsString = 3.14159.toStringAsFixed(2);
assert(piAsString == '3.14');
Posted by: Guest on April-14-2022

Code answers related to "Dart"

Browse Popular Code Answers by Language