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.
60 lines
1.7 KiB
Dart
60 lines
1.7 KiB
Dart
import 'package:cutdex_sdk/project.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
import 'package:path/path.dart' as p;
|
|
|
|
import '../errors/app_failure.dart';
|
|
|
|
part 'media_import.freezed.dart';
|
|
|
|
/// A selected local file or document supplied by a platform provider.
|
|
@freezed
|
|
sealed class ExternalMediaFile with _$ExternalMediaFile {
|
|
const ExternalMediaFile._();
|
|
const factory ExternalMediaFile({required String path}) = LocalMediaFile;
|
|
const factory ExternalMediaFile.content({
|
|
required Uri uri,
|
|
required String name,
|
|
int? byteLength,
|
|
}) = ContentMediaFile;
|
|
|
|
String? get localPath => switch (this) {
|
|
LocalMediaFile(:final path) => path,
|
|
ContentMediaFile() => null,
|
|
};
|
|
|
|
Uri get sourceUri => switch (this) {
|
|
LocalMediaFile(:final path) => p.toUri(path),
|
|
ContentMediaFile(:final uri) => uri,
|
|
};
|
|
|
|
String get displayName => switch (this) {
|
|
LocalMediaFile(:final path) => p.basename(path),
|
|
ContentMediaFile(:final name) => name,
|
|
};
|
|
}
|
|
|
|
const mediaSourceUriKey = 'cutdex.sourceUri';
|
|
|
|
String? mediaSourceLocation(AssetDocument asset) => switch (asset.storage) {
|
|
AssetStorage.external => asset.location,
|
|
AssetStorage.managed => asset.metadata[mediaSourceUriKey] as String?,
|
|
};
|
|
|
|
@freezed
|
|
abstract class MediaImportFailure with _$MediaImportFailure {
|
|
const factory MediaImportFailure({
|
|
required String name,
|
|
required AppFailure failure,
|
|
}) = _MediaImportFailure;
|
|
}
|
|
|
|
@freezed
|
|
abstract class MediaImportResult with _$MediaImportResult {
|
|
const factory MediaImportResult({
|
|
required List<AssetDocument> assets,
|
|
required int added,
|
|
required int duplicates,
|
|
required List<MediaImportFailure> failures,
|
|
}) = _MediaImportResult;
|
|
}
|