onDocumentLoadFailed property

void Function(DocumentLoadFailure failure)? onDocumentLoadFailed
final

Called when the Instant document fails to open.

This is the only reliable signal an app gets for a failed open: the viewer stays on its loading indicator. onControllerReady fires once the native view is attached, so it can arrive before or after the failure and doesn't mean the document opened. Use this callback to render your own error state, and drop any controller you stored; retry by rebuilding the widget (a new Key forces a fresh view).

The most common cause is opening a document the device has never downloaded while offline — the failure arrives within milliseconds. It is terminal: the view will not recover on its own.

NutrientInstantView(
  key: ValueKey(_attempt),
  serverUrl: serverUrl,
  jwt: jwt,
  onDocumentLoadFailed: (failure) =>
      setState(() => _error = failure.message),
)

The failure carries the native error type and, on Android, the InstantErrorCode — REQUEST_FAILED for an unreachable server, AUTHENTICATION_FAILED for a rejected JWT. iOS and Web report the message only.

Implementation

final void Function(DocumentLoadFailure failure)? onDocumentLoadFailed;