import 'package:flutter/material.dart'; import 'package:openmediacentermobile/types/actor.dart'; import 'package:openmediacentermobile/preview/actor_tile.dart'; import '../api/actor_api.dart'; import '../drawer/my_drawer.dart'; import '../screen_loading.dart'; class ActorScreen extends StatefulWidget { const ActorScreen({Key? key}) : super(key: key); @override State createState() => _ActorScreenState(); } class _ActorScreenState extends State { late Future> _categories; @override void initState() { super.initState(); _categories = loadAllActors(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Actors"), ), body: FutureBuilder( future: _categories, builder: (context, AsyncSnapshot> snapshot) { if (snapshot.connectionState != ConnectionState.done) { return ScreenLoading(); } if (snapshot.hasError) { return Text("Error"); } else if (snapshot.hasData) { return Padding( padding: EdgeInsets.all(5), child: SingleChildScrollView( child: Wrap( spacing: 5, runSpacing: 5, alignment: WrapAlignment.start, children: snapshot.data! .map((e) => ActorTile(actor: e)) .toList(growable: false), ), ), ); } else { return ScreenLoading(); } }, ), drawer: MyDrawer()); } }