app_icon_image.dart 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'dart:typed_data';
  2. import 'package:flutter/material.dart';
  3. import '../theme/app_colors.dart';
  4. /// Renders a real installed-app icon where identification matters. Used in the
  5. /// app picker, All Apps, and user-installed (non-system) home shortcuts.
  6. class AppIconImage extends StatelessWidget {
  7. const AppIconImage({super.key, this.bytes, this.size = 40});
  8. final Uint8List? bytes;
  9. final double size;
  10. @override
  11. Widget build(BuildContext context) {
  12. final colors = context.colors;
  13. final fallback = Container(
  14. width: size,
  15. height: size,
  16. decoration: BoxDecoration(
  17. color: colors.accentSoft,
  18. borderRadius: BorderRadius.circular(size * 0.26),
  19. ),
  20. alignment: Alignment.center,
  21. child: Icon(Icons.apps_rounded, size: size * 0.56, color: colors.accent),
  22. );
  23. if (bytes == null || bytes!.isEmpty) return fallback;
  24. return ClipRRect(
  25. borderRadius: BorderRadius.circular(size * 0.24),
  26. child: Image.memory(
  27. bytes!,
  28. width: size,
  29. height: size,
  30. fit: BoxFit.cover,
  31. filterQuality: FilterQuality.medium,
  32. gaplessPlayback: true,
  33. errorBuilder: (_, _, _) => fallback,
  34. ),
  35. );
  36. }
  37. }