table.dart 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import 'dart:collection';
  2. import 'package:flutter/material.dart';
  3. //所有桌状态
  4. class TableStatusList with ChangeNotifier {
  5. Map<int, TableStatus> _tableStatusMap = HashMap();
  6. get tableMap => _tableStatusMap;
  7. int size() => _tableStatusMap.length;
  8. ///如果当前台已开返回true,如果没开则返回false
  9. bool isopen(int index) {
  10. return _tableStatusMap.containsKey(index);
  11. }
  12. addtable(TableStatus tableStatus) {
  13. _tableStatusMap[tableStatus.id] = tableStatus;
  14. notifyListeners();
  15. }
  16. deletetable(int? index) {
  17. print("[删除桌号]" + index.toString());
  18. _tableStatusMap.remove(index);
  19. notifyListeners();
  20. }
  21. changetable(int before, TableStatus tableStatus) {
  22. if (!isopen(tableStatus.id)) {
  23. print("[更换桌号]" + before.toString());
  24. deletetable(before);
  25. addtable(tableStatus);
  26. }
  27. }
  28. }
  29. //桌状态
  30. class TableStatus {
  31. TableStatus(this.id);
  32. int id;
  33. bool isopen = false;
  34. }
  35. // class OrderDetails {}