NutrientDocumentView<T extends NutrientController> class
A widget for displaying PDF and image documents with typed controller access.
This widget pairs with a NutrientPlatformAdapter registered via Nutrient.addAdapterClass (or passed per-view via adapter). The adapter is the controller — it provides document-level APIs (annotations, bookmarks, forms) and receives native lifecycle callbacks so you can customize behavior via JNI/FFI/JS.
Basic Usage
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Nutrient.initialize(androidLicenseKey: 'YOUR_LICENSE_KEY');
Nutrient.addAdapterClass<MyController>(() => createMyAdapter());
runApp(const MyApp());
}
NutrientDocumentView<MyController>(
documentPath: 'assets/sample.pdf',
onControllerReady: (controller) async {
final count = await controller.document.getPageCount();
final bookmarks = await controller.document.bookmarks.getBookmarks();
},
)
Extensibility
Customize any document operation by injecting factory closures on
PdfDocument* inside your adapter's createDocument():
class MyAndroidAdapter extends AndroidAdapter implements MyController {
@override
NutrientDocumentAndroid createDocument() => NutrientDocumentAndroid(
this,
bookmarkManagerFactory: (doc) => MyBookmarks(doc),
);
}
See the Extensibility example in the example app for a full walkthrough.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- NutrientDocumentView
Constructors
- NutrientDocumentView({Key? key, String? documentPath, Uint8List? documentBytes, NutrientViewConfiguration? configuration, void onControllerReady(T controller)?, T? adapter})
-
const
Properties
- adapter → T?
-
Optional per-view adapter override.
final
- configuration → NutrientViewConfiguration?
-
Optional typed viewer configuration.
final
- documentBytes → Uint8List?
-
Document content as in-memory bytes.
final
- documentPath → String?
-
Path to the document.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onControllerReady → void Function(T controller)?
-
Called when the typed controller is ready for use.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< NutrientDocumentView< T> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited