course-work/lib/models/item.dart

36 lines
693 B
Dart
Raw Normal View History

2022-12-27 05:13:07 +00:00
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'item.g.dart';
@JsonSerializable()
class Item extends Equatable {
factory Item.fromJson(final Map<String, dynamic> json) =>
_$ItemFromJson(json);
Item({
required this.title,
required this.id,
2022-12-27 05:13:07 +00:00
this.description,
this.price,
this.quantity,
});
final String title;
2022-12-27 05:13:07 +00:00
final String? description;
final int? price;
final int id;
2022-12-27 05:13:07 +00:00
final int? quantity;
// tojson
Map<String, dynamic> toJson() => _$ItemToJson(this);
@override
List<Object?> get props => [
title,
description,
price,
id,
quantity,
];
}