I want to Know the difference between todoudle
and double.parse
in dart and where are each of them used?
The result of both is the same, but the difference may be in the compilation
I want to Know the difference between todoudle
and double.parse
in dart and where are each of them used?
The result of both is the same, but the difference may be in the compilation
2
Answers
You can only use toDouble function when type of variable is int, double or num. If you have dynamic variable, you don’t know exactly type, you want to convert to double, you can use double.parse() or double.tryParse()
double.parse is used to convert a string to a double.
Example:
toDouble is used to convert a numeric value of another data type to a double.