---
title: "Flutter PDF viewer events and notifications"
canonical_url: "https://www.nutrient.io/guides/flutter/events-and-notifications/viewer/"
md_url: "https://www.nutrient.io/guides/flutter/events-and-notifications/viewer.md"
last_updated: "2026-05-15T09:08:03.624Z"
description: "Nutrient Flutter SDK lets you listen to various events that occur when the end user interacts with Nutrient."
---

# Viewer events and notifications

Nutrient Flutter SDK allows you to listen to various events that occur when the end user interacts with Nutrient.

## NutrientView events

Nutrient Flutter SDK supports the following events:

- `onDocumentLoaded` — Called when a document is loaded with the loaded [`PdfDocument`](https://pub.dev/documentation/nutrient_flutter/latest/nutrient_flutter/PdfDocument-class.html) object. This event is triggered after the document is loaded and the first page is rendered.

- `onDocumentLoadFailed` — Called when a document fails to load. The event delivers an error message with the reason for the failure.

- `onPageChanged` — Called when a page is changed with the new page index. This event is triggered when a document is first loaded or when a user navigates to a new page.

- `onPageClicked` — Called when a page is clicked with the page index. This event is triggered when a user clicks on a page.

- `onViewCreated` — Called when the view is created. This event is triggered when the `NutrientView` is initialized and ready to be used.

To listen to these events, add an event listener to the [`NutrientView`](https://pub.dev/documentation/nutrient_flutter/latest/nutrient_flutter/NutrientView-class.html):

```dart

NutrientView(
	document: document_path,
	onDocumentLoaded: (pdfDocument) {
		print('Document loaded');
	},
	onDocumentLoadFailed: (error) {
		print('Document load failed: $error');
	},
	onPageChanged: (pageIndex) {
		print('Page changed to $pageIndex');
	},
	onPageClicked: (pageIndex) {
		print('Page clicked: $pageIndex');
	},
);

```

## Present mode events

The following table lists the events supported by Nutrient Flutter SDK in present mode.

| **Event**                      | **Description**                                                         |
| ------------------------------ | ----------------------------------------------------------------------- |
| `flutterPdfActivityOnPause`    | Android only. Called when the PDF activity is paused.                   |
| `pdfViewControllerWillDismiss` | iOS only. Called right before the dismissal of the PDF view controller. |
| `pdfViewControllerDidDismiss`  | iOS only. Called right after the dismissal of the PDF view controller.  |

### Implementing a callback method

The example below shows how to implement a callback to get notified when the PDF activity is paused or when the PDF view controller is about to be dismissed.

```dart

// First, implement the callback methods:

void flutterPdfActivityOnPauseHandler() {
	print('flutterPdfActivityOnPauseHandler');
}

void pdfViewControllerWillDismissHandler() {
	print('pdfViewControllerWillDismissHandler');
}

void pdfViewControllerDidDismissHandler() {
	print('pdfViewControllerDidDismissHandler');
}

// Next, register these callbacks with `Nutrient` once. This can be done in the `build` method of your widget.
Nutrient.flutterPdfActivityOnPause = () => flutterPdfActivityOnPauseHandler();
Nutrient.pdfViewControllerWillDismiss = () => pdfViewControllerWillDismissHandler();
Nutrient.pdfViewControllerDidDismiss = () => pdfViewControllerDidDismissHandler();

```

Now, whenever any of these events happen, the corresponding method will trigger and print the relevant text.
---

## Related pages

- [Analytics events and notifications](/guides/flutter/events-and-notifications/analytics.md)
- [PDF form events and notifications](/guides/flutter/events-and-notifications/forms.md)
- [PDF events and notifications](/guides/flutter/events-and-notifications.md)
- [Annotation events and notifications](/guides/flutter/events-and-notifications/annotation.md)
- [Text selection events and notifications](/guides/flutter/events-and-notifications/text-selection.md)

