import 'dart:convert'; import 'package:intl/intl.dart' show toBeginningOfSentenceCase; class IoniaGiftCardInstruction { IoniaGiftCardInstruction(this.header, this.body); factory IoniaGiftCardInstruction.fromJsonMap(Map element) { return IoniaGiftCardInstruction( toBeginningOfSentenceCase(element['title'] as String? ?? '') ?? '', element['description'] as String); } static List parseListOfInstructions(String instructionsJSON) { List instructions = []; if (instructionsJSON.isNotEmpty) { final decodedInstructions = json.decode(instructionsJSON) as List; instructions = decodedInstructions .map((dynamic e) =>IoniaGiftCardInstruction.fromJsonMap(e as Map)) .toList(); } return instructions; } final String header; final String body; }