| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import 'dart:typed_data';
- import 'package:flutter/material.dart';
- import '../theme/app_colors.dart';
- /// Renders a real installed-app icon where identification matters. Used in the
- /// app picker, All Apps, and user-installed (non-system) home shortcuts.
- 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,
- ),
- );
- }
- }
|