SheetRow<T>.timed constructor

SheetRow<T>.timed(
  1. List<double> durations, {
  2. T? key,
  3. int? start,
  4. bool? loop,
})

A row that holds each of its frames for its own number of seconds.

Plays as many frames as durations is long.

Implementation

SheetRow.timed(
  List<double> durations, {
  this.key,
  int? start,
  this.loop,
}) : start = start ?? 0,
     frames = null,
     fps = null,
     durations = .unmodifiable(durations) {
  if (durations.isEmpty) {
    throw ArgumentError.value(
      durations,
      'durations',
      'Must hold at least one frame.',
    );
  }

  for (var index = 0; index < durations.length; index += 1) {
    final duration = durations[index];

    if (duration <= 0 || !duration.isFinite) {
      throw ArgumentError.value(
        duration,
        'durations[$index]',
        'Must be positive and finite.',
      );
    }
  }
}