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
Future<List<dynamic>> getItems() async {
Future<List<Item>> getItems() async {
var resp = jsonDecode(await getRequest("$instance/items"));
var lst = resp["items"];
return lst as List<dynamic>;
var lst = resp["items"] as List<dynamic>;
return lst.map((x) => Item(x)).toList();
}
Future<GlobalItemStat> getGlobalItemStat() async {

View file

@ -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),
);
}
}