garage_state.dart 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:shared/utils/color_utils.dart';
  4. class GarageState {
  5. List<Map<String, dynamic>>? topSectionsData;
  6. int? curPage;
  7. int? pageSize;
  8. int? filterCount;
  9. int? activeIndex = 0;
  10. List tabsList = [];
  11. List<Map<String,dynamic>> categoryList = [];
  12. List? list = [];
  13. GarageState({
  14. this.topSectionsData,
  15. this.curPage,
  16. this.pageSize,
  17. this.filterCount,
  18. this.activeIndex,
  19. List<Map<String, dynamic>>? categoryList,
  20. required this.tabsList,
  21. this.list,
  22. }): categoryList = categoryList ?? [];
  23. GarageState copyWith({
  24. List<Map<String, dynamic>>? topSectionsData,
  25. List<Map<String, dynamic>>? categoryList,
  26. int? curPage,
  27. int? pageSize,
  28. int? filterCount,
  29. int? activeIndex,
  30. List? tabsList,
  31. List? list,
  32. }) {
  33. return GarageState(
  34. topSectionsData: topSectionsData ?? this.topSectionsData,
  35. curPage: curPage ?? this.curPage,
  36. pageSize: pageSize ?? this.pageSize,
  37. filterCount: filterCount ?? this.filterCount,
  38. activeIndex: activeIndex ?? this.activeIndex,
  39. categoryList: categoryList ?? this.categoryList,
  40. tabsList: tabsList ?? this.tabsList,
  41. list: list ?? this.list,
  42. );
  43. }
  44. Map<String, dynamic> toMap() {
  45. return {
  46. 'topSectionsData': this.topSectionsData,
  47. 'curPage': this.curPage,
  48. 'pageSize': this.pageSize,
  49. 'filterCount': this.filterCount,
  50. 'activeIndex': this.activeIndex,
  51. 'tabsList': this.tabsList,
  52. 'list': this.list,
  53. 'categoryList': this.categoryList,
  54. };
  55. }
  56. factory GarageState.fromMap(Map<String, dynamic> map) {
  57. return GarageState(
  58. topSectionsData: map['topSectionsData'] as List<Map<String, dynamic>>,
  59. curPage: map['curPage'] as int,
  60. pageSize: map['pageSize'] as int,
  61. filterCount: map['filterCount'] as int,
  62. activeIndex: map['activeIndex'] as int,
  63. tabsList: map['tabsList'] as List,
  64. list: map['list'] as List,
  65. );
  66. }
  67. }