favoriteCard.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:video/model/video.dart';
  4. import 'package:video/utils/screen.dart';
  5. class FavoriteCard extends StatelessWidget {
  6. final Video video;
  7. const FavoriteCard({this.video});
  8. @override
  9. Widget build(BuildContext context) {
  10. return InkWell(
  11. child: Column(
  12. children: <Widget>[
  13. CachedNetworkImage(
  14. imageUrl: video.imageUrl,
  15. placeholder: _loader,
  16. errorWidget: _error,
  17. height: Screen.bottomSafeHeight + 170,
  18. width: Screen.width,
  19. ),
  20. Text(video.title),
  21. ],
  22. ),
  23. onTap: () {
  24. Navigator.pushNamed(
  25. context,
  26. 'detail',
  27. arguments: {"url": video.url, "video": video},
  28. );
  29. },
  30. );
  31. }
  32. Widget _loader(BuildContext context, String url) {
  33. return const Center(
  34. child: CircularProgressIndicator(),
  35. );
  36. }
  37. Widget _error(BuildContext context, String url, dynamic error) {
  38. print(error);
  39. return const Center(child: Icon(Icons.error));
  40. }
  41. }