flutter

String to double conversion in flutter [Dart]

To convert a string to double type in flutter or dart, you can use double.parse() method.

String val = "1.8";
double result = double.parse(val);
print(result);
// -> 1.8

The method double.parse(value) takes the value as a required parameter and returns the value in double type format.

In the code snippet, we have defined a string format variable named val that needs to be converted to a double type format. We are using double.parse(val) to convert this string variable to double.

Was this helpful?