show static method
Future<void>
show(
- BuildContext context,
- VideoEditorController controller, {
- bool listen = false,
Opens the sheet and runs the edit the user confirms.
Implementation
static Future<void> show(
BuildContext context,
VideoEditorController controller, {
bool listen = false,
}) async {
if (!controller.hasProject) {
EditorFeedback.showMessage(context, 'Add clips first');
return;
}
final request = await EditorSheetScaffold.show<_AutoEditRequest>(
context,
(_) => AutoEditSheet(controller: controller, listen: listen),
);
if (request == null || !context.mounted) return;
final status = ValueNotifier('Starting the edit…');
final agent = EditAgent();
try {
final report = await runWithProgress(
context,
'AI editing…',
(_) async {
var plan = request.plan;
if (request.useSmartAi && request.text.trim().isNotEmpty) {
status.value = 'Understanding your request…';
plan = await agent.understand(request.text, template: request.template);
}
if (plan.isEmpty) {
final empty = AutoEditReport()
..skipped.add(
'I could not turn that into edits. Try one of the suggestions, '
'or pick a style.',
);
return empty;
}
return AutoEditor(controller, agent: agent).run(
plan,
onStatus: (s) => status.value = s,
captionLanguage: request.language,
useSmartAi: request.useSmartAi,
);
},
status: status,
);
if (!context.mounted) return;
await AiEditResultSheet.show(context, report);
} catch (e) {
if (!context.mounted) return;
EditorFeedback.showMessage(
context,
'AI edit failed: ${e.toString().replaceAll('Exception: ', '')}',
);
}
}