You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
773B

  1. import 'package:get/get.dart';
  2. class ChangeUnit extends GetxController {
  3. List<String> currentUnits;
  4. String selectedUnit;
  5. initValue() {
  6. currentUnits = [];
  7. selectedUnit = "";
  8. update();
  9. }
  10. updateListByUnitName(String unitName) {
  11. if (unitName == "kg" || unitName == "g") {
  12. currentUnits = ["kg", "g"];
  13. selectedUnit = unitName;
  14. } else if (unitName == "l" || unitName == "m") {
  15. currentUnits = ["l", "ml"];
  16. selectedUnit = unitName;
  17. } else if (unitName == "m" || unitName == "cm" || unitName == "mm") {
  18. currentUnits = ["m", "cm", "mm"];
  19. selectedUnit = unitName;
  20. } else {
  21. currentUnits = [];
  22. }
  23. update();
  24. }
  25. updateSelected(String selected) {
  26. selectedUnit = selected;
  27. update();
  28. }
  29. }