From 9e0d19751bbfc3398b962cfc5728a60193266a62 Mon Sep 17 00:00:00 2001 From: cho4u4o Date: Mon, 21 Oct 2024 01:29:44 +0900 Subject: [PATCH] fix : return empty array when error occurs --- lib/screens/products/item_list_page.dart | 4 ++-- lib/screens/products/liked_list_page.dart | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/screens/products/item_list_page.dart b/lib/screens/products/item_list_page.dart index 994ccc7..9af8d94 100644 --- a/lib/screens/products/item_list_page.dart +++ b/lib/screens/products/item_list_page.dart @@ -46,10 +46,10 @@ class _ItemListPageState extends State { .toList(); return products; } else { - throw Exception('No results found in the response'); + return []; } } else { - throw Exception('Failed to load products'); + return []; } } catch (e) { return []; diff --git a/lib/screens/products/liked_list_page.dart b/lib/screens/products/liked_list_page.dart index eb8d9f9..5f054ca 100644 --- a/lib/screens/products/liked_list_page.dart +++ b/lib/screens/products/liked_list_page.dart @@ -207,9 +207,8 @@ class _LikedListPageState extends State { return InkWell( onTap: () { setState(() { - // URL에 따라 제품을 다시 가져오고, 상태를 업데이트합니다. _products = getProducts(url); - countProducts(url); // 필터에 맞는 제품 개수를 카운트합니다. + countProducts(url); }); }, child: Container(