getNumericOnly method

String getNumericOnly({
  1. bool aFirstWordOnly = false,
})

toast a String Returns only numbers from a string trim Whitespaces

Implementation

/*  void toastString() {
  toast(this);
}*/

/// Returns only numbers from a string trim Whitespaces
String getNumericOnly({bool aFirstWordOnly = false}) {
  String numericOnlyString = '';

  for (var i = 0; i < this.validate().length; i++) {
    if ((this![i].isDigit())) {
      numericOnlyString += this![i];
    }
    if (aFirstWordOnly && numericOnlyString.isNotEmpty && this![i] == " ") {
      break;
    }
  }

  return numericOnlyString;
}