news_state.dart 1.1 KB

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