fix item id

This commit is contained in:
JMARyA 2024-09-21 02:05:45 +02:00
parent 4b9e616581
commit db0841d716
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
2 changed files with 7 additions and 7 deletions

View file

@ -52,10 +52,10 @@ class API {
} }
// /items // /items
Future<List<dynamic>> getItems() async { Future<List<Item>> getItems() async {
var resp = jsonDecode(await getRequest("$instance/items")); var resp = jsonDecode(await getRequest("$instance/items"));
var lst = resp["items"]; var lst = resp["items"] as List<dynamic>;
return lst as List<dynamic>; return lst.map((x) => Item(x)).toList();
} }
Future<GlobalItemStat> getGlobalItemStat() async { Future<GlobalItemStat> getGlobalItemStat() async {

View file

@ -30,7 +30,7 @@ class ItemsPage extends StatelessWidget {
} }
class ItemTile extends StatelessWidget { class ItemTile extends StatelessWidget {
final String item; final Item item;
const ItemTile(this.item, {super.key}); const ItemTile(this.item, {super.key});
@ -38,10 +38,10 @@ class ItemTile extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListTile( return ListTile(
onTap: () { onTap: () {
API().getItem(item).then((itemInfo) => Navigator.push(context, Navigator.push(context,
MaterialPageRoute(builder: (context) => ItemView(item: itemInfo)))); MaterialPageRoute(builder: (context) => ItemView(item: item)));
}, },
title: Text(item), title: Text(item.name),
); );
} }
} }