fromJsonArray static method

TransactionResultList fromJsonArray(
  1. String jsonArry
)

Implementation

static TransactionResultList fromJsonArray(String jsonArry) {
  List jsonDecoded = json.decode(jsonArry);

  jsonDecoded.forEach((element) {
    int index = jsonDecoded.indexOf(element);
    if (element['redValue'] == '') {
      jsonDecoded[index]['redValue'] = "0";
    }
    if (element['greenValue'] == '') {
      jsonDecoded[index]['greenValue'] = "0";
    }
  });

  List<TransactionResult> myApiResponse =
      jsonDecoded.map((item) => TransactionResult.fromJson(item)).toList();

  return TransactionResultList(myApiResponse);
}