updateClothingItem static method

Future<void> updateClothingItem(
  1. ClothingItem item
)

更新衣物

Implementation

static Future<void> updateClothingItem(ClothingItem item) async {
  final prefs = await SharedPreferences.getInstance();
  final items = await getAllClothingItems();

  final index = items.indexWhere((i) => i.id == item.id);
  if (index != -1) {
    items[index] = item;
    final jsonList = items.map((item) => item.toJson()).toList();
    await prefs.setString(_keyClothingItems, jsonEncode(jsonList));
  }
}