stringFromJson static method

String? stringFromJson(
  1. Map<String, dynamic> json,
  2. String attribute, {
  3. String? defaultValue,
})

Implementation

static String? stringFromJson(Map<String, dynamic> json, String attribute,
    {String? defaultValue}) {
  try {
    return json[attribute] != null
        ? json[attribute].toString()
        : defaultValue;
  } catch (e) {
    throw Exception('Error while parsing $attribute[$e]');
  }
}