import 'package:cdb_ui/api.dart'; import 'package:cdb_ui/itemview.dart'; import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'CDB', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: const HomePage(), ); } } class HomePage extends StatelessWidget { const HomePage({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text("Home Page")), body: Column(children: [ const Row(children: [Text("Stats about everything")]), FutureBuilder( future: API().getItems(), builder: (context, snapshot) { if (!snapshot.hasData) { return const CircularProgressIndicator(); } var items = snapshot.data!; return Expanded( child: GridView.count( crossAxisCount: 2, children: items.map((x) { return ItemCard(x); }).toList(), )); }) ]), ); } } class ItemCard extends StatelessWidget { final String item; const ItemCard(this.item, {super.key}); @override Widget build(BuildContext context) { return InkWell( onTap: () async { var itemInfo = await API().getItem(item); Navigator.push(context, MaterialPageRoute(builder: (context) => ItemView(item: itemInfo))); }, child: Row(children: [ Image.network( API().getImageURL(item), width: 128, height: 128, ), Text(item) ]), ); } }