How to convert to double

Remove the quotes from

 var long2 = double.parse('$group1');


 var long2 = double.parse($group1);

You can also use

var long2 = double.tryParse($group1);

or to also accept numbers without fractions

var long2 = num.tryParse($group1)?.toDouble();

to not get an exception when the string in $group1 can not be converted to a valid double.

Leave a Comment