getContextEvent method Null safety

SynthizerEvent? getContextEvent(
  1. Context context
)

Get the next event for context.

Implementation

SynthizerEvent? getContextEvent(Context context) {
  SynthizerEvent? value;
  check(synthizer.syz_contextGetNextEvent(
      _eventPointer, context.handle.value, 0));
  final sourceHandle = _eventPointer.ref.source;
  final eventType = _eventPointer.ref.type.toEventTypes();
  switch (eventType) {
    case EventTypes.finished:
      value = FinishedEvent(context, getObject(sourceHandle));
      break;
    case EventTypes.looped:
      value = LoopedEvent(context, getObject(sourceHandle) as Generator);
      break;
    case EventTypes.userAutomation:
      value = UserAutomationEvent(context, getObject(sourceHandle),
          _eventPointer.ref.payload.user_automation.param);
      break;
    case EventTypes.invalid:
      return null;
  }
  synthizer.syz_eventDeinit(_eventPointer);
  return value;
}