Nutrient class

Main entry point for the Nutrient Flutter Bindings plugin.

This class provides ONLY:

  • SDK initialization with license key
  • Platform adapter registration and management
  • SDK version information

All other functionality (navigation, annotations, forms, events, etc.) is provided through platform adapters.

Basic Usage

Initialize with just a license key:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Nutrient.initialize(
    licenseKey: 'YOUR_LICENSE_KEY',
  );

  runApp(MyApp());
}

Advanced Usage with Platform Adapters

Register custom adapters for advanced functionality:

await Nutrient.initialize(
  licenseKey: 'YOUR_LICENSE_KEY',
  androidAdapter: MyAndroidAdapter(),
  iosAdapter: MyIOSAdapter(),
  webAdapter: MyWebAdapter(),
);

// Later, access the adapter
final adapter = Nutrient.currentAdapter;
adapter.events.listen((event) {
  // Handle events
});

Constructors

Nutrient()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

androidAdapter NutrientPlatformAdapter?
Get the Android platform adapter.
no setter
androidLicenseKey String?
Get the Android license key.
no setter
currentAdapter NutrientPlatformAdapter?
Get the current platform adapter.
no setter
currentLicenseKey String?
Get the license key for the current platform.
no setter
frameworkVersion Future<String?>
The version of the underlying native Nutrient SDK on the current platform (Android, iOS, or Web) — for example "11.5.1".
no setter
iosAdapter NutrientPlatformAdapter?
Get the iOS platform adapter.
no setter
iosLicenseKey String?
Get the iOS license key.
no setter
isInitialized bool
Whether the SDK has been initialized.
no setter
version String
The version of the Nutrient Flutter bindings.
no setter
webAdapter NutrientPlatformAdapter?
Get the Web platform adapter.
no setter
webLicenseKey String?
Get the Web license key.
no setter

Static Methods

addAdapterClass<T extends NutrientController>(T create()) → void
Register a builder for controller type T.
buildAdapter<T extends NutrientController>() → T
Build the controller for a NutrientDocumentView<T>.
hasAdapterClass<T extends NutrientController>() bool
Whether a builder is registered for T.
initialize({String? androidLicenseKey, String? iosLicenseKey, String? webLicenseKey, NutrientPlatformAdapter? androidAdapter, NutrientPlatformAdapter? iosAdapter, NutrientPlatformAdapter? webAdapter}) Future<void>
Initialize the Nutrient SDK.
isSharedAdapter(NutrientController controller) bool
Whether controller is the process-shared adapter resolved from the (deprecated) global slots for the current platform — i.e. not a per-view instance that the view created and therefore owns.
openDocument(String path, {String? password, NutrientController? adapter}) Future<NutrientDocumentInterface>
Opens a document without a viewer (headless), returning the full document API — annotations, bookmarks, forms, save, export — with no UI.
openDocumentFromBytes(Uint8List bytes, {String? password, NutrientController? adapter}) Future<NutrientDocumentInterface>
Opens a document from in-memory bytes without a viewer (headless).
processAnnotations({required String sourcePath, required AnnotationType type, required AnnotationProcessingMode mode, required String destinationPath, NutrientController? adapter}) Future<bool>
Processes the annotations of the document at sourcePath and writes the result to destinationPath, mirroring the legacy SDK's Nutrient.processAnnotations.
removeAdapterClass<T extends NutrientController>() → void
Remove a builder previously registered for T via addAdapterClass.
reset() Future<void>
Reset the SDK state (for testing only).