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?
Similar Posts
- Convert a double to an int in Dart or Flutter
- Get current timestamp in flutter or dart
- Find number of days between two dates in Flutter or Dart
- Send HTTP Get request in Flutter or Dart
- Send HTTP POST request in Flutter or Dart
- Ternary Conditional operator in Flutter(Dart)
- Converting class objects to JSON string in Flutter