store_item.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import 'package:clean/utils/expand.dart';
  2. import 'package:json_annotation/json_annotation.dart';
  3. part 'store_item.g.dart';
  4. @JsonSerializable()
  5. class StoreItem {
  6. @JsonKey(name: "id")
  7. late int id;
  8. @JsonKey(name: "sort")
  9. late int sort;
  10. @JsonKey(name: "name")
  11. late String name;
  12. @JsonKey(name: "appleGoodsId")
  13. late String appleGoodsId;
  14. @JsonKey(name: "subscribable")
  15. late int subscribable;
  16. @JsonKey(name: "amount")
  17. late int amount;
  18. @JsonKey(name: "originalAmount")
  19. late int originalAmount;
  20. @JsonKey(name: "auth")
  21. late String auth;
  22. @JsonKey(name: "subscriptionMillis")
  23. late int subscriptionMillis;
  24. @JsonKey(name: "priceDesc")
  25. late String? priceDesc;
  26. @JsonKey(name: "freeTrialPriceDesc")
  27. late String? freeTrialPriceDesc;
  28. @JsonKey(name: "freeTrialName")
  29. late String? freeTrialName;
  30. @JsonKey(name: "coefficient")
  31. late int coefficient;
  32. StoreItem({
  33. required this.id,
  34. required this.sort,
  35. required this.name,
  36. required this.appleGoodsId,
  37. required this.subscribable,
  38. required this.amount,
  39. required this.originalAmount,
  40. required this.auth,
  41. required this.subscriptionMillis,
  42. required this.priceDesc,
  43. required this.coefficient,
  44. this.freeTrialName,
  45. this.freeTrialPriceDesc,
  46. });
  47. get amountText => (amount / 100).toFormattedString(2);
  48. get originalAmountText => (originalAmount / 100).toFormattedString(2);
  49. factory StoreItem.fromJson(Map<String, dynamic> json) =>
  50. _$StoreItemFromJson(json);
  51. }