getMemberMediumModelChainOfMedium static method

Future<List<MemberMediumModel>> getMemberMediumModelChainOfMedium(
  1. String? appId,
  2. MemberMediumModel memberMediumModel
)

Implementation

static Future<List<MemberMediumModel>> getMemberMediumModelChainOfMedium(
    String? appId, MemberMediumModel memberMediumModel) async {
  var infos = <MemberMediumModel>[];
  var currentPolicy = memberMediumModel;
  infos.add(currentPolicy);
  while (currentPolicy.relatedMediumId != null) {
    var newPolicy = await memberMediumRepository(appId: appId)!
        .get(currentPolicy.relatedMediumId);
    if (newPolicy == null) {
      print("Can't get policy");
    } else {
      currentPolicy = newPolicy;
      infos.add(currentPolicy);
    }
  }
  return infos;
}