subtracks/lib/app/ui/images.dart
austinried 6609671ae2 cover art color scheme extraction (in background)
refactor text styles to use theme
port over part of album screen
2025-12-03 13:22:14 +09:00

46 lines
1.3 KiB
Dart

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:material_symbols_icons/symbols.dart';
import '../state/source.dart';
class CoverArtImage extends HookConsumerWidget {
const CoverArtImage({
super.key,
this.coverArt,
this.thumbnail = true,
this.fit,
this.height,
this.width,
});
final String? coverArt;
final bool thumbnail;
final BoxFit? fit;
final double? height;
final double? width;
@override
Widget build(BuildContext context, WidgetRef ref) {
final source = ref.watch(sourceProvider);
final sourceId = ref.watch(sourceIdProvider);
final imageUrl = coverArt != null
? source.coverArtUri(coverArt!, thumbnail: thumbnail).toString()
: 'https://placehold.net/400x400.png';
return CachedNetworkImage(
height: height,
width: width,
imageUrl: imageUrl,
cacheKey: '$sourceId$coverArt$thumbnail',
placeholder: (context, url) => Icon(Symbols.cached_rounded),
errorWidget: (context, url, error) => Icon(Icons.error),
fit: BoxFit.cover,
fadeOutDuration: Duration(milliseconds: 100),
fadeInDuration: Duration(milliseconds: 200),
);
}
}