Fakultas Ilmu Komputer UI

product.dart 1.11 KB
Newer Older
1
2
3
4
5
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';

part 'product.g.dart';

Michael Wiryadinata Halim's avatar
Michael Wiryadinata Halim committed
6
@JsonSerializable(nullable: false, fieldRename: FieldRename.snake)
7
8
9
10
11
12
13
14
15
16
class Product extends Equatable {
  final String id;
  final String name;
  final String category;

  final String categoryName;
  final String subcategory;
  final String subcategoryName;
  final String description;
  final String price;
Michael Wiryadinata Halim's avatar
Michael Wiryadinata Halim committed
17
18

  @JsonKey(nullable: true)
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  final int stock;

  @JsonKey(nullable: true)
  final String image;

  const Product(
      {this.id,
      this.name,
      this.category,
      this.categoryName,
      this.subcategory,
      this.subcategoryName,
      this.description,
      this.price,
      this.stock,
      this.image});
  factory Product.fromJson(Map<String, dynamic> json) =>
      _$ProductFromJson(json);

  Map<String, dynamic> toJson() => _$ProductToJson(this);

  @override
  List<Object> get props => [
        id,
        name,
        category,
        categoryName,
        subcategory,
        subcategoryName,
        description,
        price,
        stock,
Michael Wiryadinata Halim's avatar
Michael Wiryadinata Halim committed
51
        image,
52
53
      ];
}