parseList<T> static method

List<T>? parseList<T>({
  1. required Object? value,
  2. required String name,
  3. bool throwOnNull = false,
})

Implementation

static List<T>? parseList<T>(
    {required Object? value,
    required String name,
    bool throwOnNull = false}) {
  if (value == null && !throwOnNull) return null;
  try {
    return List<T>.from(value as List);
  } catch (e) {
    if (!throwOnNull) return null;
  }
  if (value == null) {
    throw TronPluginException("Missing parameter: $name.");
  }
  throw TronPluginException("Invalid List value for parameter: $name.");
}