parsePosterTime function
The Time for a --poster value (1.5s, 30f, 500ms), or null (no
poster) for null/empty.
Throws an ArgumentError naming the value when it carries no known unit, so a typo surfaces as a stated error rather than a silently missing poster.
Implementation
Time? parsePosterTime(String? poster) {
if (poster == null || poster.isEmpty) return null;
if (poster.endsWith('ms')) return Time.ms(int.parse(poster.substring(0, poster.length - 2)));
if (poster.endsWith('s')) {
return Time.seconds(double.parse(poster.substring(0, poster.length - 1)));
}
if (poster.endsWith('f')) return Time.frames(int.parse(poster.substring(0, poster.length - 1)));
throw ArgumentError.value(poster, 'poster', 'expected a Time string like 1.5s, 30f or 500ms');
}