digitsBefore method
Get the digits before a substring
in the number
Returns the digits before a substring
in the number
Implementation
num digitsBefore(num substring) {
var index = toString().indexOf(substring.toString());
if (index == -1) return 0;
var result = toString().substring(0, index);
return int.parse(result);
}