numeric static method

String? numeric(
  1. String? value, [
  2. String? message
])

Numeric only

Implementation

static String? numeric(String? value, [String? message]) {
  if (value == null || value.isEmpty) return null;
  if (double.tryParse(value) == null) {
    return message ?? 'Please enter a valid number';
  }
  return null;
}