Files
cutdex/lib/features/media/media_asset_cover.dart
T
lingjhf 27e77fff39 feat: initial Cutdex application
Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
2026-10-05 23:36:23 +08:00

39 lines
1.0 KiB
Dart

import 'package:cutdex_sdk/project.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../integrations/runtime/media_presentations.dart';
/// Subscribes to one cover frame so loading it only rebuilds its image.
class MediaAssetCover extends ConsumerWidget {
const MediaAssetCover({
super.key,
required this.asset,
required this.fallback,
this.errorFallback,
this.fit = BoxFit.contain,
this.timeMilliseconds = 0,
});
final AssetDocument asset;
final Widget fallback;
final Widget? errorFallback;
final BoxFit fit;
final int timeMilliseconds;
@override
Widget build(BuildContext context, WidgetRef ref) {
final bytes = ref
.watch(mediaCoverProvider(asset, timeMilliseconds: timeMilliseconds))
.value;
return bytes == null
? fallback
: Image.memory(
bytes,
fit: fit,
excludeFromSemantics: true,
errorBuilder: (_, _, _) => errorFallback ?? fallback,
);
}
}