HapticPattern constructor
HapticPattern(
- List<
HapticPulse> pulses
Implementation
HapticPattern(this.pulses) {
if (pulses.isEmpty) {
throw ArgumentError.value(pulses, 'pulses', 'must not be empty');
}
if (pulses.length > maxPulses) {
throw ArgumentError.value(
pulses,
'pulses',
'must not exceed $maxPulses pulses',
);
}
for (final pulse in pulses) {
if (pulse.delayAfter.isNegative) {
throw ArgumentError.value(
pulse.delayAfter,
'delayAfter',
'must not be negative',
);
}
if (pulse.delayAfter > maxDelayPerPulse) {
throw ArgumentError.value(
pulse.delayAfter,
'delayAfter',
'must not exceed $maxDelayPerPulse',
);
}
}
final total = pulses.fold<Duration>(
Duration.zero,
(sum, pulse) => sum + pulse.delayAfter,
);
if (total > maxTotalDuration) {
throw ArgumentError.value(
total,
'pulses',
'total delay must not exceed $maxTotalDuration',
);
}
}