getProfiles method

Future<List<MixedProfile>> getProfiles({
  1. String? referenceToken,
  2. List<String>? type,
})

returns a MixedProfile which will have fields for m1.Profile or m2.MediaProfile depending on what is supported by the device.

Implementation

Future<List<MixedProfile>> getProfiles({
  String? referenceToken,
  List<String>? type,
}) async {
  List<m2.MediaProfile>? mediaProfiles;

  List<m1.Profile>? profiles;

  final mixedProfiles = <MixedProfile>[];

  if (_mediaSupportLevel == MediaSupportLevel.one) {
    profiles = await media1.getProfiles();

    for (var profile in profiles) {
      mixedProfiles.add(MixedProfile.fromProfile(profile));
    }
  } else {
    mediaProfiles =
        await media2.getProfiles(referenceToken: referenceToken, type: type);

    for (var mediaProfile in mediaProfiles) {
      mixedProfiles.add(MixedProfile.fromMediaProfile(mediaProfile));
    }
  }

  if (mediaProfiles == null && profiles == null) {
    throw NotSupportedException();
  }

  return mixedProfiles;
}