asFloat function

double? asFloat(
  1. String text,
  2. {double? defaultValue}
)

Converts a text into an integer. defaultValue is the return value if text is not an integer

Implementation

double? asFloat(String text, {double? defaultValue}) {
  var rc = defaultValue;
  if (text.isNotEmpty) {
    try {
      rc = double.parse(text);
    } on FormatException {
      // nothing to do
    }
  }
  return rc;
}