image_cache.dart 815 B

12345678910111213141516171819202122232425
  1. import 'package:flutter/material.dart';
  2. import '../utils/utils.dart';
  3. class ShowImageCache extends StatelessWidget {
  4. const ShowImageCache({Key? key}) : super(key: key);
  5. ImageCache? get imageCache => PaintingBinding.instance?.imageCache;
  6. @override
  7. Widget build(BuildContext context) {
  8. return Column(mainAxisAlignment: MainAxisAlignment.center, children: [
  9. const SizedBox(height: 8),
  10. Text(
  11. '当前图像缓存数量: ${imageCache?.currentSize ?? 0}',
  12. style: const TextStyle(fontSize: 12),
  13. ),
  14. const SizedBox(height: 8),
  15. Text(
  16. '当前图像缓存大小: ${imageCache?.currentSizeBytes ?? 0}bytes = ${byte2MB(imageCache?.currentSizeBytes ?? 0)}MB',
  17. style: const TextStyle(fontSize: 12),
  18. ),
  19. const SizedBox(height: 8),
  20. ]);
  21. }
  22. }