toNum static method

num toNum(
  1. dynamic object, {
  2. dynamic mapKey,
  3. int? listIndex,
  4. String? format,
  5. String? locale,
  6. num? defaultValue,
  7. ElementConverter<num>? converter,
})

Converts object to num, honoring NumberOptions defaults.

If format is provided or NumberOptions.defaultFormat is set, formatted parsing is attempted in the order defined by NumberOptions.tryFormattedFirst, then falls back to plain parsing. Throws ConversionException when parsing fails and defaultValue is null.

Implementation

static num toNum(
  dynamic object, {
  dynamic mapKey,
  int? listIndex,
  String? format,
  String? locale,
  num? defaultValue,
  ElementConverter<num>? converter,
}) => ConvertObjectImpl.toNum(
  object,
  mapKey: mapKey,
  listIndex: listIndex,
  format: format,
  locale: locale,
  defaultValue: defaultValue,
  converter: converter,
);