import 'package:flutter/material.dart'; import '../api/actor_api.dart'; import '../screen_loading.dart'; import '../types/actor.dart'; class AddActorDialog extends StatefulWidget { const AddActorDialog({Key? key, required this.movieId}) : super(key: key); final int movieId; @override State createState() => _AddActorDialogState(); } class _AddActorDialogState extends State { late Future> actors = loadAllActors(); @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return AlertDialog( scrollable: true, title: Text("Add Actor"), content: FutureBuilder( future: actors, builder: (context, snapshot) { if (snapshot.hasError) { return Text("Error"); } else if (snapshot.hasData) { final data = snapshot.data! as List; return Column( mainAxisSize: MainAxisSize.min, children: data .map((e) => ListTile( title: Text(e.name), onTap: () async { await addActorToVideo(e.actorId, widget.movieId); Navigator.pop(context, e); }, )) .toList(), ); } else { return ScreenLoading(); } }, )); } }