Suppose a = 1, and we want to convert it to double Two Approaches I know:-
double.parse(a.toString())
a * 1.0
Which one is more efficient and why?
Also if anyone knows another approach let me know
Thanks!
EDIT
Alternative Approaches:
a.toDouble()
-Oshibka404this has to do with Complexity.
double x = a * 1.0;
this runs only once.
double x = double.parse(a.toString());
technically this runs 2 or more times. it converts to a string first and then convert it to a double. (pop into the double definitions in the flutter framework to learn more.)
so first method is simpler and efficient.