LiveSubtitle.create constructor
LiveSubtitle.create({})
Create a new subtitle with auto-calculated expiration Duration is based on text length: min 3 seconds, +50ms per character, max 8 seconds
Implementation
factory LiveSubtitle.create({
required String text,
required String language,
required String speakerId,
required String speakerName,
}) {
final now = DateTime.now();
// Calculate display duration: 3s base + 50ms per character, capped at 8s
final durationMs = (3000 + (text.length * 50)).clamp(3000, 8000);
return LiveSubtitle(
text: text,
language: language,
timestamp: now,
expiresAt: now.add(Duration(milliseconds: durationMs)),
speakerId: speakerId,
speakerName: speakerName,
);
}