isNumeric static method

String? isNumeric(
  1. String? checkValue, {
  2. String? errorMessage,
})

Checks that checkValue can be turned into a number

If checkValue can't be turned into a number the function will return errorMessage if provided, or the default error if not. Otherwise null is returned

Implementation

static String? isNumeric(String? checkValue, {String? errorMessage}) {
  if (checkValue == null || num.tryParse(checkValue) == null) {
    return errorMessage ?? "Field must be a valid number";
  }
  return null;
}