following_state.dart 1.5 KB

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