parseInt<T> static method

T parseInt<T>({
  1. required Object? value,
  2. required String name,
})

Implementation

static T parseInt<T>({required Object? value, required String name}) {
  if (0 is! T) {
    throw const TronPluginException(
        "Invalid type casting for numeric parser.");
  }
  if (value == null && null is T) return null as T;
  if (value == null) {
    throw TronPluginException("Missing parameter: $name.");
  }

  final parse = IntUtils.tryParse(value);
  if (parse != null) {
    return parse as T;
  }
  throw TronPluginException("Invalid numeric value for parameter: $name.");
}