sub_category_provide.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_note/model/category_model.dart';
  3. class SubCategoryProvide with ChangeNotifier {
  4. // 商品列表
  5. List<BxMallSubDtoListBean> _bxMallSubs = [];
  6. // 大类 id
  7. var _categoryId = '';
  8. // 小类 id
  9. var _subCategoryId = '';
  10. // 当前选择的小类 item index
  11. var _subIndex = 0;
  12. List<BxMallSubDtoListBean> get subCategories => _bxMallSubs;
  13. String get categoryId => _categoryId;
  14. String get subCategoryId => _subCategoryId;
  15. int get subIndex => _subIndex;
  16. // 修改左侧栏
  17. void changeLeftHeadCategories(List<BxMallSubDtoListBean> categories) {
  18. BxMallSubDtoListBean allSubDto = BxMallSubDtoListBean()
  19. ..mallCategoryId = ''
  20. ..mallSubId = null
  21. ..comments = ''
  22. ..mallSubName = '全部';
  23. _bxMallSubs.clear();
  24. _bxMallSubs.add(allSubDto);
  25. _bxMallSubs.addAll(categories);
  26. _subCategoryId = '';
  27. _subIndex = 0;
  28. notifyListeners();
  29. }
  30. // 修改大类
  31. void changeCategory(String categoryId) {
  32. _categoryId = categoryId;
  33. notifyListeners();
  34. }
  35. // 修改小类
  36. void changeSubCategorySelect(String subCategoryId) {
  37. _subCategoryId = subCategoryId;
  38. notifyListeners();
  39. }
  40. // 小类 index
  41. void changeSubCategoryIndex(int index) {
  42. _subIndex = index;
  43. notifyListeners();
  44. }
  45. }