news_state.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import 'package:widgets/load_state_layout.dart';
  2. class NewsState {
  3. //页面 LoadView 状态的展示
  4. LoadState loadingState;
  5. String? errorMessage;
  6. int? curPage;
  7. int? pageSize = 10;
  8. int? filterCount = 0;
  9. List<Map<String, dynamic>>? list = [];
  10. NewsState({
  11. this.loadingState = LoadState.State_Loading,
  12. String? errorMessage,
  13. this.curPage = 1,
  14. this.pageSize = 10,
  15. this.filterCount = 0,
  16. this.list,
  17. });
  18. NewsState copyWith({
  19. LoadState? loadingState,
  20. String? errorMessage,
  21. int? curPage,
  22. int? pageSize,
  23. int? filterCount,
  24. List<Map<String, dynamic>>? list,
  25. List<String>? tabsList,
  26. }) {
  27. return NewsState(
  28. loadingState: loadingState ?? this.loadingState,
  29. errorMessage: errorMessage ?? this.errorMessage,
  30. curPage: curPage ?? this.curPage,
  31. pageSize: pageSize ?? this.pageSize,
  32. filterCount: filterCount ?? this.filterCount,
  33. list: list ?? this.list,
  34. );
  35. }
  36. Map<String, dynamic> toMap() {
  37. return {
  38. 'loadingState': this.loadingState,
  39. 'errorMessage': this.errorMessage,
  40. 'curPage': this.curPage,
  41. 'pageSize': this.pageSize,
  42. 'filterCount': this.filterCount,
  43. 'list': this.list,
  44. };
  45. }
  46. factory NewsState.fromMap(Map<String, dynamic> map) {
  47. return NewsState(
  48. loadingState: map['loadingState'] as LoadState,
  49. errorMessage: map['errorMessage'] as String,
  50. curPage: map['curPage'] as int,
  51. pageSize: map['pageSize'] as int,
  52. filterCount: map['filterCount'] as int,
  53. list: map['list'] as List<Map<String, dynamic>>,
  54. );
  55. }
  56. }