Hibok
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

58 lignes
1.3 KiB

  1. part of 'photo_main_page.dart';
  2. class ImageItem extends StatelessWidget {
  3. final AssetEntity entity;
  4. final Color themeColor;
  5. final int size;
  6. final LoadingDelegate loadingDelegate;
  7. const ImageItem({
  8. Key key,
  9. this.entity,
  10. this.themeColor,
  11. this.size = 64,
  12. this.loadingDelegate,
  13. }) : super(key: key);
  14. @override
  15. Widget build(BuildContext context) {
  16. var thumb = ImageLruCache.getData(entity, size);
  17. if (thumb != null) {
  18. return _buildImageItem(context, thumb);
  19. }
  20. return FutureBuilder<Uint8List>(
  21. future: entity.thumbDataWithSize(size, size),
  22. builder: (BuildContext context, AsyncSnapshot<Uint8List> snapshot) {
  23. var futureData = snapshot.data;
  24. if (snapshot.connectionState == ConnectionState.done &&
  25. futureData != null) {
  26. ImageLruCache.setData(entity, size, futureData);
  27. return _buildImageItem(context, futureData);
  28. }
  29. return Center(
  30. child: loadingDelegate.buildPreviewLoading(
  31. context,
  32. entity,
  33. themeColor,
  34. ),
  35. );
  36. },
  37. );
  38. }
  39. Widget _buildImageItem(BuildContext context, Uint8List data) {
  40. return Image.memory(
  41. data,
  42. width: double.infinity,
  43. height: double.infinity,
  44. fit: BoxFit.cover,
  45. );
  46. }
  47. }