toJson method

Map<String, dynamic> toJson()

Converts this Item object into a JSON object.

The resulting JSON will follow the same format as required by Item.fromJson.

Implementation

Map<String, dynamic> toJson() {
  return {
    'name': name,
    'quantity': quantity,
    'price': price,
    'category': category.toLowerCase(),
  };
}