getAllClothingItems static method

Future<List<ClothingItem>> getAllClothingItems()

获取所有衣物

Implementation

static Future<List<ClothingItem>> getAllClothingItems() async {
  final prefs = await SharedPreferences.getInstance();
  final String? data = prefs.getString(_keyClothingItems);
  if (data == null) return [];

  try {
    final List<dynamic> jsonList = jsonDecode(data);
    return jsonList.map((json) => ClothingItem.fromJson(json)).toList();
  } catch (e) {
    return [];
  }
}