From db0841d7167f31942360d7f0602ce1a52153e31e Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sat, 21 Sep 2024 02:05:45 +0200 Subject: [PATCH] fix item id --- lib/api.dart | 6 +++--- lib/pages/items.dart | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/api.dart b/lib/api.dart index c276010..25033a9 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -52,10 +52,10 @@ class API { } // /items - Future> getItems() async { + Future> getItems() async { var resp = jsonDecode(await getRequest("$instance/items")); - var lst = resp["items"]; - return lst as List; + var lst = resp["items"] as List; + return lst.map((x) => Item(x)).toList(); } Future getGlobalItemStat() async { diff --git a/lib/pages/items.dart b/lib/pages/items.dart index 217f427..fb28f1f 100644 --- a/lib/pages/items.dart +++ b/lib/pages/items.dart @@ -30,7 +30,7 @@ class ItemsPage extends StatelessWidget { } class ItemTile extends StatelessWidget { - final String item; + final Item item; const ItemTile(this.item, {super.key}); @@ -38,10 +38,10 @@ class ItemTile extends StatelessWidget { Widget build(BuildContext context) { return ListTile( onTap: () { - API().getItem(item).then((itemInfo) => Navigator.push(context, - MaterialPageRoute(builder: (context) => ItemView(item: itemInfo)))); + Navigator.push(context, + MaterialPageRoute(builder: (context) => ItemView(item: item))); }, - title: Text(item), + title: Text(item.name), ); } }