cart_count_provide.dart 410 B

1234567891011121314151617181920212223
  1. import 'package:flutter/material.dart';
  2. /// 用于购物车的选择数量
  3. class CartCountProvide with ChangeNotifier {
  4. int _count = 1;
  5. int get shopCount => _count;
  6. initCount() {
  7. _count = 1; // 打开时候初始化
  8. notifyListeners();
  9. }
  10. increase() {
  11. _count += 1; // 增加按钮
  12. notifyListeners();
  13. }
  14. decrease() {
  15. _count -= 1; // 减少按钮
  16. notifyListeners();
  17. }
  18. }