extractNumbers method

List<num> extractNumbers()

Extracts all numbers (int and double) from this string.

'\$12.5 off, save 3 items'.extractNumbers() // [12.5, 3]

Implementation

List<num> extractNumbers() {
  final matches = RegExp(r'-?\d+\.?\d*').allMatches(this);
  return matches.map((m) => num.parse(m[0]!)).toList();
}