MBRelationElement constructor

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

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

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

Implementation

factory MBRelationElement({required Map<String, dynamic> dictionary}) {
  List<MBRelation> relations = [];

  dynamic value = dictionary['value'];
  if (value != null) {
    if (value is Map<String, dynamic>) {
      relations = [MBRelation(dictionary: value)];
    } else if (value is List<dynamic>) {
      List<Map<String, dynamic>> relationsFromDict =
          List.castFrom<dynamic, Map<String, dynamic>>(value);
      relations =
          relationsFromDict.map((r) => MBRelation(dictionary: r)).toList();
    }
  }
  return MBRelationElement._(
    dictionary: dictionary,
    relations: relations,
  );
}