rewards_home_state.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /// YApi QuickType插件生成,具体参考文档:https://plugins.jetbrains.com/plugin/18847-yapi-quicktype/documentation
  2. import 'dart:convert';
  3. import 'package:domain/entity/rewards_home_entity.dart';
  4. import 'package:widgets/load_state_layout.dart';
  5. // RewardsHomeState rewardsHomeStateFromJson(String str) =>
  6. // RewardsHomeState.fromJson(json.decode(str));
  7. String rewardsHomeStateToJson(RewardsHomeState data) =>
  8. json.encode(data.toJson());
  9. class RewardsHomeState {
  10. //页面 LoadView 状态的展示
  11. LoadState loadingState;
  12. String? errorMessage;
  13. List<Map<String, dynamic>> list;
  14. List<Map<String, dynamic>> lists;
  15. List<Map<String, dynamic>>? categoryList;
  16. RewardsHomeState({
  17. this.loadingState = LoadState.State_Loading,
  18. String? errorMessage,
  19. required this.list,
  20. required this.lists,
  21. required this.categoryList,
  22. });
  23. RewardsHomeState copyWith(
  24. {LoadState? loadingState,
  25. String? errorMessage,
  26. List<Map<String, dynamic>>? categoryList,
  27. List<Map<String, dynamic>>? list,
  28. List<Map<String, dynamic>>? lists}) {
  29. return RewardsHomeState(
  30. loadingState: loadingState ?? this.loadingState,
  31. errorMessage: errorMessage ?? this.errorMessage,
  32. list: list ?? this.list,
  33. lists: lists ?? this.lists,
  34. categoryList: list ?? this.categoryList,
  35. );
  36. }
  37. Map<String, dynamic> toMap() {
  38. return {
  39. 'list': List<dynamic>.from(lists.map((x) => x)),
  40. "lists": List<dynamic>.from(lists.map((x) => x)),
  41. 'categoryList': this.categoryList,
  42. };
  43. }
  44. Map<dynamic, dynamic> toJson() => {
  45. "lists": List<dynamic>.from(lists.map((x) => x)),
  46. };
  47. factory RewardsHomeState.fromJson(Map<dynamic, dynamic> json, dynamic map) =>
  48. RewardsHomeState(
  49. lists: List<Map<String, dynamic>>.from(json["lists"].map((x) => x)),
  50. list: List<Map<String, dynamic>>.from(json["lists"].map((x) => x)),
  51. categoryList: map['categoryList'] as List<Map<String, dynamic>>,
  52. );
  53. factory RewardsHomeState.fromMap(Map<String, dynamic> map, dynamic json) {
  54. return RewardsHomeState(
  55. list: List<Map<String, dynamic>>.from(json["lists"].map((x) => x)),
  56. lists: List<Map<String, dynamic>>.from(json["lists"].map((x) => x)),
  57. categoryList: map['categoryList'] as List<Map<String, dynamic>>,
  58. );
  59. }
  60. }