parse static method
Parse a distance from a string
Implementation
static Distance parse(String s) {
final int? parsedInt = int.tryParse(s);
final double? parsedDouble = double.tryParse(s);
if (parsedInt != null) {
return Distance.fixed(parsedInt);
} else if (parsedDouble != null) {
return Distance.proportional(parsedDouble);
} else {
throw Exception("Cannot parse Distance from given string '$s'");
}
}