fromMap static method

Product fromMap(
  1. Map<String, dynamic> data
)

Implementation

static Product fromMap(Map<String, dynamic> data) => Product(
      id: data['id'],
      name: data['name'] ?? '',
      description: data['description'] ?? '',
      price: (data['price'] is int)
          ? (data['price'] as int).toDouble()
          : (data['price'] as double? ?? 0.0),
      type: ProductType.values[data['type'] ?? 0],
      listingType: ListingType.values[data['listingType'] ?? 0],
      sellerId: data['sellerId'] ?? '',
      location: data['location'],
      createdAt: data['createdAt'] != null
          ? DateTime.parse(data['createdAt'])
          : DateTime.now(),
      images: data['images'] != null ? List<String>.from(data['images']) : null,
      isAvailable: data['isAvailable'] ?? true,
    );