addClothingItem static method

Future<void> addClothingItem(
  1. ClothingItem item
)

添加衣物

Implementation

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

  final jsonList = items.map((item) => item.toJson()).toList();
  await prefs.setString(_keyClothingItems, jsonEncode(jsonList));
}