MBMediaElement constructor

MBMediaElement({
  1. required Map<String, dynamic> dictionary,
})

Initializes a media element with the dictionary returned by the MBurger APIs.

  • Parameters:
    • dictionary: The dictionary returned by the APIs.

Implementation

factory MBMediaElement({required Map<String, dynamic> dictionary}) {
  List<MBMedia> media = [];
  if (dictionary['value'] is List) {
    List<Map<String, dynamic>> value =
        List<Map<String, dynamic>>.from(dictionary['value'] as List);
    media = value.map((img) => MBMedia(dictionary: img)).toList();
  }

  String? type;
  if (dictionary['type'] is String) {
    type = dictionary['type'] as String;
  }
  MBMediaType mediaType = _mediaTypeForString(type);

  return MBMediaElement._(
    dictionary: dictionary,
    media: media,
    mediaType: mediaType,
  );
}