import 'dart:io'; import 'package:flutter/material.dart'; import 'package:tangocard_reader/screens/misc/error.dart'; import 'package:tangocard_reader/screens/misc/loading.dart'; class TangoSetList extends StatelessWidget { final String route; final Future> files; const TangoSetList({ Key? key, required this.route, required this.files, }) : super(key: key); @override Widget build(BuildContext context) => FutureBuilder( future: files, builder: (context, snapshot) { if (snapshot.hasError) { debugPrint(snapshot.error.toString()); return const ErrorScreen(); } else if (!snapshot.hasData) { return const LoadingScreen(); } return ListView( children: (snapshot.data as Map) .entries .map( (e) => ListTile( title: Text( "${e.key.uri.pathSegments.last} - ${e.value.length} cards"), onTap: () => Navigator.pushNamed( context, route, arguments: e.key, ), ), ) .toList(), ); }, ); }