create method

  1. @override
Future<PresetRecord> create(
  1. PresetState preset
)
override

Implementation

@override
Future<PresetRecord> create(PresetState preset) async {
  await client.create(preset);

  final record = await client.presetUpdates
      // Don't check equality of the parameter values, they will have rounding
      // errors after roundtrip through the firmware, instead just check the
      // name.
      .firstWhere((element) => element.preset.name == preset.name)
      .timeout(const Duration(seconds: 2));

  final newValue = _presets.value..[record.id] = record;
  _presets.add(newValue);

  return record;
}