digitsBeforeLast method
Get the digits before the last occurrence of substring
in the number
Returns the digits before the last occurrence of substring
in the number
Implementation
num digitsBeforeLast(num substring) {
var index = toString().lastIndexOf(substring.toString());
if (index == -1) return 0;
var result = toString().substring(0, index);
return int.parse(result);
}