parseMap<K, V> static method

Map<K, V>? parseMap<K, V>({
  1. required Object? value,
  2. required String name,
  3. dynamic throwOnNull = false,
})

Implementation

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