Files
cutdex/lib/features/assistant/composer_reference_validator.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

33 lines
930 B
Dart

import '../../workspace/project_state.dart';
import 'composer_document.dart';
/// Checks draft references against the project currently open in the composer.
final class ComposerReferenceValidator {
const ComposerReferenceValidator({
required this.workspace,
required this.projectId,
});
final ProjectState? workspace;
final String? projectId;
bool isValid(ComposerReference reference) {
if (projectId != reference.projectId ||
workspace?.activeProject?.id != reference.projectId) {
return false;
}
return switch (reference.kind) {
ComposerReferenceKind.media => workspace!.assets.any(
(asset) => asset.id == reference.id,
),
ComposerReferenceKind.timeline => workspace!.timelines.any(
(timeline) => timeline.id == reference.id,
),
};
}
void validate(ComposerDocumentController document) {
document.updateValidity(isValid);
}
}