getPublicMediumModelChainOfMediumInfo static method

Future<List<MediumInfo>> getPublicMediumModelChainOfMediumInfo(
  1. String? appId,
  2. PublicMediumModel publicMediumModel
)

Implementation

static Future<List<MediumInfo>> getPublicMediumModelChainOfMediumInfo(
    String? appId, PublicMediumModel publicMediumModel) async {
  var infos = <MediumInfo>[];
  var currentPolicy = publicMediumModel;
  _addPublicMediumInfo(infos, currentPolicy);
  while (currentPolicy.relatedMediumId != null) {
    var newPolicy = await publicMediumRepository(appId: appId)!
        .get(currentPolicy.relatedMediumId);
    if (newPolicy == null) {
      print("Can't get policy");
    } else {
      currentPolicy = newPolicy;
      _addPublicMediumInfo(infos, currentPolicy);
    }
  }
  return infos;
}