getPlanDetails method

Map getPlanDetails(
  1. BuildContext context,
  2. String id
)

Implementation

Map getPlanDetails(BuildContext context, String id) {
  List subs = context
      .read<AdBase>()
      .data!['subscription_config'];
  List temp0 = subs.where((element) => element['id'] == id).toList();

  ///[No Server Declaration]
  if (temp0.isEmpty) {
    return {};
  }

  ///[No Offer Declaration]
  if (temp0[0]['offer_id'] == null) {
    return {};
  }

  List temp =
  subs.where((element) => element['id'] == temp0[0]['offer_id']).toList();
  List temp1 = products.where((element) => element.id == id).toList();

  return {
    "product": temp0.isNotEmpty ? temp0[0] : null,
    "offer": temp.isNotEmpty ? temp[0] : null,
    "appStore": temp1.isNotEmpty ? temp1[0] : null,
  };
}