import 'package:flutter/material.dart'; import 'package:f0ckapp/model/item.dart'; import 'package:f0ckapp/api/fetchitem.dart'; class ItemPage extends StatefulWidget { final int id; const ItemPage({Key? key, required this.id }) : super(key: key); @override // ignore: library_private_types_in_public_api _ItemPageState createState() => _ItemPageState(); } class _ItemPageState extends State with SingleTickerProviderStateMixin { late final int id; late Future f0ck; @override void initState() { super.initState(); id = widget.id; f0ck = fetchItemFromApi(id); } @override Widget build(BuildContext context) { return FutureBuilder( future: f0ck, builder: (context, snapshot) { if(snapshot.hasData) { return Scaffold( appBar: AppBar( title: Text('f0ck $id'), ), body: Column( children: [ AspectRatio( aspectRatio: 1, child: SizedBox( width: double.infinity, child: snapshot.data!.mime.startsWith('image') ? Image.network("https://f0ck.dev/b/${snapshot.data?.dest}") : const Text("no image"), ), ), Container( margin: const EdgeInsets.all(20.0), child: Center( child: Text( "${snapshot.data?.mime}", style: const TextStyle(fontSize: 40), ), ), ), ], ), ); } else if(snapshot.hasError) { return Text("${snapshot.error}"); } return const CircularProgressIndicator(); } ); } }