rewards_search_state.dart 2.0 KB

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