Annotation events and notifications
Nutrient Flutter SDK emits events when users interact with annotations in a document. Subscribe to the typed controller.events streams from the NutrientDocumentView onControllerReady callback.
The SDK supports the following annotation events:
| Stream | Event | Description |
|---|---|---|
controller.events.annotationCreated | AnnotationCreatedEvent | The SDK emits this when users create annotations. |
controller.events.annotationUpdated | AnnotationUpdatedEvent | The SDK emits this when users update annotations. |
controller.events.annotationDeleted | AnnotationDeletedEvent | The SDK emits this when users delete annotations. |
controller.events.annotationSelected | AnnotationSelectedEvent | The SDK emits this when users select annotations. |
controller.events.annotationDeselected | AnnotationDeselectedEvent | The SDK emits this when users deselect annotations. |
Each event exposes the following data:
event.annotations— The affected annotations as typedAnnotationmodels.event.types— TheAnnotationTypevalues for the affected annotations. Use this to filter events by annotation type.event.annotationsJson— The raw Instant JSON.
The following example listens for created ink annotations:
NutrientDocumentView( documentPath: documentPath, onControllerReady: (controller) { controller.events.annotationCreated.listen((event) { if (event.types.contains(AnnotationType.ink)) { for (final annotation in event.annotations) { print('Created: ${annotation.type.name} on page ${annotation.pageIndex}'); } } }); },)For advanced customization, use the Nutrient native and web SDKs. Refer to the Nutrient Flutter SDK customization guide and the following guides for more information: