splitTextOverlay method

void splitTextOverlay(
  1. String id,
  2. Duration projectTime
)

Implementation

void splitTextOverlay(String id, Duration projectTime) {
  final index = textOverlays.indexWhere((o) => o.id == id);
  if (index == -1) return;

  final overlay = textOverlays[index];
  final splitAt = projectTime == Duration.zero ? _currentGlobalTime.value : projectTime;
  final currentEnd = overlay.effectiveEndTime;

  if (splitAt <= overlay.startTime || splitAt >= currentEnd) {
    return;
  }

  textController.updateTextTiming(id, overlay.startTime, splitAt);

  final newOverlay = overlay.copyWith(
    id: '${overlay.id}_split_${DateTime.now().microsecondsSinceEpoch}',
    startTime: splitAt,
    endTime: currentEnd,
  );

  textController.addTextOverlay(newOverlay);
  _saveState();
  notifyListeners();
}