import 'dart:typed_data'; import 'package:flutter/material.dart'; import '../theme/app_colors.dart'; /// Renders a real installed-app icon where identification matters (the app /// picker and All Apps). Dashboard shortcut icons stay generic. class AppIconImage extends StatelessWidget { const AppIconImage({super.key, this.bytes, this.size = 40}); final Uint8List? bytes; final double size; @override Widget build(BuildContext context) { final colors = context.colors; final fallback = Container( width: size, height: size, decoration: BoxDecoration( color: colors.accentSoft, borderRadius: BorderRadius.circular(size * 0.26), ), alignment: Alignment.center, child: Icon(Icons.apps_rounded, size: size * 0.56, color: colors.accent), ); if (bytes == null || bytes!.isEmpty) return fallback; return ClipRRect( borderRadius: BorderRadius.circular(size * 0.24), child: Image.memory( bytes!, width: size, height: size, fit: BoxFit.cover, filterQuality: FilterQuality.medium, gaplessPlayback: true, errorBuilder: (_, _, _) => fallback, ), ); } }