setEventHandler method

void setEventHandler(
  1. AnnotationEventHandler handler
)

Sets the annotation event handler.

After setting the annotation event handler, you can listen for annotation events and receive the statistics of the corresponding RtcAnnotation instance.

Parameter handler The event handler.

Implementation

void setEventHandler(AnnotationEventHandler handler) {
  _handler = handler;
  _subscription ??= _eventChannel.receiveBroadcastStream().listen((event) {
    final eventMap = Map<dynamic, dynamic>.from(event);
    final annotationId = eventMap['annotationId'];
    final methodName = eventMap['methodName'] as String?;
    final data = List<dynamic>.from(eventMap['data']);
    RtcAnnotationManager.annotations[annotationId]?._handler
        ?.process(methodName, data);
  });
}