This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/flutter/instant-synchronization/instant-view.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. NutrientInstantView widget for Flutter | Nutrient SDK

NutrientInstantView embeds a live collaborative PDF document directly in your Flutter widget tree. It connects to a Nutrient Document Engine server and renders the document with real-time annotation syncing, so multiple users can see each other’s changes.

Platform support: Android, iOS, and Web.

Server setup

Before you use the NutrientInstantView widget, set up a running Document Engine instance and create a signed JSON Web Token (JWT) for the target document. Refer to these guides for setup details:

Basic usage

Add the widget to your widget tree. Set serverUrl to the base URL of your Document Engine instance and pass a signed JWT whose document_id claim names the document. The widget fills its available space, so wrap it in Expanded, SizedBox, or another layout widget.

NutrientInstantView(
serverUrl: 'https://your-server.example.com/',
jwt: 'eyJhbGci...',
onViewCreated: (NutrientViewHandle handle) {
// The native view is ready. Store the handle for programmatic access
// to annotations, page navigation, and other document operations.
},
)

Constructor parameters

Use these parameters to configure the Instant document connection, viewer behavior, and controller lifecycle.

ParameterTypeRequiredDescription
serverUrlStringYesBase URL of your Document Engine server — for example, https://your-server.example.com/. The JWT’s document_id claim selects the document
jwtStringYesSigned JWT with at least read-document and write permissions
configurationNutrientViewConfiguration?NoViewer appearance and behavior options. Refer to the view configuration guide
onViewCreatedvoid Function(NutrientViewHandle)?NoCalled once the native view has initialized
onDocumentLoadFailedvoid Function(DocumentLoadFailure)?NoCalled when the document fails to open. Refer to handle load failures
onControllerReadyvoid Function(T)?NoSurfaces the Instant controller once ready on Android and iOS
adapterT?NoPer-view controller instance you own, on Android and iOS (ignored on Web). Refer to custom controllers for lifecycle requirements
keyKey?NoStandard Flutter widget key

The Instant controller

onControllerReady surfaces a NutrientInstantController(opens in a new tab). This controller provides the regular controller surface, such as document and events, plus Instant sync controls:

NutrientInstantView(
serverUrl: serverUrl,
jwt: jwt,
onControllerReady: (controller) async {
// Instant sync controls (Android and iOS):
await controller.setDelayForSyncingLocalChanges(2); // Seconds.
await controller.setListenToServerChanges(true);
await controller.syncAnnotations();
// Typed Instant events (buffered — no events are missed).
controller.events.instantSyncFinished.listen((e) {
print('In sync: ${e.documentId}');
});
},
)

On Web, these controls aren’t available. The Web SDK configures Instant sync at load time and manages syncing, and onControllerReady isn’t called.

Custom controllers

NutrientInstantView uses the same adapter model as NutrientDocumentView:

  • Bare NutrientInstantView(...) — The platform creates the default Instant controller for this view and disposes it with the view.
  • Typed NutrientInstantView<MyInstantController>(...) — The view creates an instance from the factory registered with Nutrient.addAdapterClass<MyInstantController>(...) and owns its lifecycle. MyInstantController must implement NutrientInstantController.
  • Per-view instance with adapter: — You allocate and dispose the controller. The view only attaches and detaches it.

On Web, the view manages its own controller, so typed controllers and adapter: have no effect.

For more information about the adapter model, refer to the platform adapters guide.

Apply configuration

Use NutrientViewConfiguration to customize the viewer’s layout, user interface (UI), and editing capabilities. Platform-specific options are grouped under androidConfig and iosConfig:

NutrientInstantView(
serverUrl: serverUrl,
jwt: jwt,
configuration: const NutrientViewConfiguration(
pageLayoutMode: PageLayoutMode.single,
thumbnailBarMode: ThumbnailBarMode.floating,
enableAnnotationEditing: true,
enableFormEditing: true,
enableInstantComments: true,
aiAssistantConfiguration: {
'serverUrl': 'https://your-ai-assistant-server.com',
'jwt': 'your-ai-assistant-jwt',
'sessionId': 'unique-session-id',
},
androidConfig: AndroidViewConfiguration(
showSearchAction: true,
showOutlineAction: true,
),
iosConfig: IOSViewConfiguration(
spreadFitting: SpreadFitting.adaptive,
),
),
)

enableInstantComments and aiAssistantConfiguration only apply to Android and iOS Instant documents. For a complete list of options, refer to the view configuration guide.

Reconnect and change documents

serverUrl and jwt are fixed at construction time. The native SDK establishes the WebSocket connection once and doesn’t observe changes to these values. To switch to a different document or refresh an expired JWT, force the widget to rebuild by changing its key.

A common pattern stores an integer counter in state and increments it whenever new connection settings apply:

int _viewKey = 0;
void _applyNewConnection(String serverUrl, String jwt) {
setState(() {
_serverUrl = serverUrl;
_jwt = jwt;
_viewKey++; // Forces NutrientInstantView to rebuild with new values.
});
}
NutrientInstantView(
key: ValueKey(_viewKey),
serverUrl: _serverUrl!,
jwt: _jwt!,
)

Handle load failures

If the document fails to open, the viewer stays on its loading indicator on Android and iOS. Don’t treat onControllerReady as a sign that the document opened: On Android and iOS, it fires once the native view is attached, and it can arrive before or after the failure is reported. Use onDocumentLoadFailed to detect the failure, show your own error state, and drop any controller you stored. The most common cause is opening a document that the device has never downloaded while offline.

On iOS, onDocumentLoadFailed reports failures that happen while the document downloads. If serverUrl isn’t a valid URL or the JWT is malformed or has no document_id claim, the iOS view stays blank. None of onViewCreated, onControllerReady, and onDocumentLoadFailed is called. Check these values before you build the view.

The failure is terminal, and the view doesn’t retry on its own. To try again, rebuild the widget with a new key, as described in reconnect and change documents:

DocumentLoadFailure? _failure;
int _attempt = 0;
@override
Widget build(BuildContext context) {
final failure = _failure;
if (failure != null) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text("Couldn't open the document: ${failure.message}"),
// `code` is only reported on Android.
if (failure.code != null) Text('Error code: ${failure.code}'),
FilledButton(
onPressed: () => setState(() {
_failure = null;
_attempt++; // A new key builds a fresh view.
}),
child: const Text('Retry'),
),
],
),
);
}
return NutrientInstantView(
key: ValueKey(_attempt),
serverUrl: serverUrl,
jwt: jwt,
onDocumentLoadFailed: (failure) => setState(() => _failure = failure),
);
}

DocumentLoadFailure(opens in a new tab) has these fields:

FieldTypeDescription
messageStringHuman-readable description of the failure. Never empty
typeString?Native error type, for example InstantDownloadException. Android only
codeString?Native InstantErrorCode name — for example, REQUEST_FAILED when the server can’t be reached or AUTHENTICATION_FAILED for a rejected JWT. Android only

On iOS and Web, type and code are null, so use message there. On Android and iOS, the same failure is also emitted on the controller’s events stream as a DocumentErrorEvent. This is useful when you pass your own controller with adapter:.

Complete example

The instant_example in the Catalog app(opens in a new tab) shows a complete working example, including a connection sheet, a status indicator, and platform-specific configuration.