getGiftData method

void getGiftData()

Implementation

void getGiftData() async {
  if (GiftStore().giftModelList.isNotEmpty) {
    return;
  }
  String dataJson =
      await GiftCacheManager.getCachedJson(Constants.giftDataUrl);
  debugPrint("GiftManager dataJson:${dataJson.length}");
  if (dataJson.isNotEmpty) {
    Map<String, dynamic> jsonMap = jsonDecode(dataJson);
    if (jsonMap.containsKey("giftList")) {
      List<GiftModel> giftList = (jsonMap['giftList'] as List)
          .map((e) => GiftModel.fromJson(e))
          .toList();
      GiftStore().giftModelList = giftList;
      debugPrint("GiftManager giftModelList:${GiftStore().giftModelList}");
    } else {
      debugPrint("GiftManager jsonMap:$jsonMap");
    }
  }
}