digitsBeforeFirst method

num digitsBeforeFirst(
  1. num substring
)

Get the digits before the first occurrence of substring in the number Returns the digits before the first occurrence of substring in the number

Implementation

num digitsBeforeFirst(num substring) {
  var index = toString().indexOf(substring.toString());
  if (index == -1) return 0;
  var result = toString().substring(0, index);
  return int.parse(result);
}