Files
SpotiFLAC-Mobile/lib/widgets/player_queue_artwork.dart
zarzet 962e582acc chore(flutter): move to Flutter 3.50.0 and the material_ui packages
Flutter 3.50 deprecates its built-in Material and Cupertino libraries in
favour of the material_ui and cupertino_ui packages. The imports move
with the official fix (dart fix, migrate_design_widgets); the app's old
two-library theme bridge collapses into one Theme type.

- MaterialExpressiveScope keeps the complete host theme nearest its
  child. The reduced copy made for the expressive widgets now shares the
  app's Theme type and would hide component themes and extensions.
- LegacyThemeBrightness hands the brightness to the glass package, which
  still reads Flutter's built-in theme.
- appLocalizationsDelegates lists the material_ui localization delegates;
  the generated list still names the built-in ones.
- Tests: findByTooltip and pageBack replace the flutter_test helpers that
  only know the built-in widgets, and several tests that had gone stale
  against earlier app changes are repaired.
2026-11-15 23:33:29 +07:00

65 lines
1.9 KiB
Dart

import 'package:audio_service/audio_service.dart';
import 'package:material_ui/material_ui.dart';
import 'package:path/path.dart' as p;
import 'package:mornye/services/cover_store.dart';
import 'package:mornye/widgets/cached_cover_image.dart';
import 'package:mornye/widgets/local_library_artwork_builder.dart';
import 'package:mornye/widgets/player_artwork.dart';
/// Queue entries may not have artwork yet, as for files a phone sent through
/// Link. Recover only visible rows through the shared bounded cover cache.
class PlayerQueueArtwork extends StatelessWidget {
const PlayerQueueArtwork({
super.key,
required this.item,
required this.colorScheme,
required this.cacheWidth,
this.iconSize = 22,
});
final MediaItem item;
final ColorScheme colorScheme;
final int cacheWidth;
final double iconSize;
String? get _localSource {
var source = item.extras?['source']?.toString() ?? item.id;
if (source.startsWith('file://')) {
try {
source = Uri.parse(source).toFilePath();
} on FormatException {
return null;
} on UnsupportedError {
return null;
}
}
return p.isAbsolute(source) || source.startsWith('content://')
? source
: null;
}
@override
Widget build(BuildContext context) {
// A network cover not stored yet shows once a visible row fetched it.
final artwork =
item.artUri?.toString() ?? item.extras?['artworkRef']?.toString();
final source = _localSource;
Widget image(String? uri) => PlayerArtwork(
artUri: uri,
colorScheme: colorScheme,
cacheWidth: cacheWidth,
iconSize: iconSize,
);
if (source == null ||
isHttpCoverUrl(artwork) ||
CoverStore.fetches(artwork)) {
return image(artwork);
}
return LocalLibraryArtworkBuilder(
coverPath: artwork,
filePath: source,
builder: (_, cover) => image(cover),
);
}
}