MBShopifyCollection constructor

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

Initializes an address element with the dictionary returned by the MBurger APIs.

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

Implementation

factory MBShopifyCollection({required Map<String, dynamic> dictionary}) {
  String collectionId = '';
  String collectionName = '';
  String? image;

  if (dictionary['id'] is int) {
    int intCollectionId = dictionary['id'] as int;
    collectionId = intCollectionId.toString();
  } else {
    collectionId = dictionary['id'] as String;
  }

  if (dictionary['text'] is String) {
    collectionName = dictionary['text'] as String;
  }

  if (dictionary['image'] != null) {
    Map<String, dynamic> imageDict =
        dictionary['image'] as Map<String, dynamic>;
    if (imageDict['src'] != null) {
      image = imageDict['src'] as String;
    }
  }
  return MBShopifyCollection._(
    collectionId: collectionId,
    collectionName: collectionName,
    image: image,
  );
}