説明なし

favorites_page.dart 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'package:flutter/material.dart';
  2. import 'custom_info_card.dart';
  3. class FavoritesPage extends StatelessWidget {
  4. final List<Map<String, dynamic>> favoriteCards;
  5. const FavoritesPage({super.key, required this.favoriteCards});
  6. @override
  7. Widget build(BuildContext context) {
  8. return Scaffold(
  9. appBar: AppBar(
  10. flexibleSpace: Padding(
  11. padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top - 20),
  12. child: Image.asset(
  13. 'assets/header_image.png',
  14. fit: BoxFit.cover,
  15. ),
  16. ),
  17. toolbarHeight: MediaQuery.of(context).size.height * 0.19,
  18. title: const Text('Mis Favoritos', style: TextStyle(color: Colors.white)),
  19. ),
  20. body: Container(
  21. decoration: const BoxDecoration(
  22. gradient: LinearGradient(
  23. colors: [Color.fromARGB(255, 254, 100, 91), Colors.orange],
  24. begin: Alignment.topCenter,
  25. end: Alignment.bottomCenter,
  26. ),
  27. ),
  28. child: favoriteCards.isEmpty
  29. ? const Center(
  30. child: Text(
  31. 'No tienes favoritos aún',
  32. style: TextStyle(color: Colors.white, fontSize: 18),
  33. ),
  34. )
  35. : ListView.builder(
  36. padding: const EdgeInsets.only(top: 16),
  37. itemCount: favoriteCards.length,
  38. itemBuilder: (context, index) {
  39. final card = favoriteCards[index];
  40. return CustomInfoCard(
  41. imagePath: "assets/icons/${card['image']}",
  42. title: card['title'],
  43. subtitle: card['subtitle'],
  44. texto: card['texto'],
  45. isFavorite: true,
  46. );
  47. },
  48. ),
  49. ),
  50. );
  51. }
  52. }