Nutrient 4 migration guide
Nutrient Flutter SDK 4 introduces a significant update with native API bridging using Pigeon, a change that requires updating your project to utilize the new API. This guide will help you transition to the new API, including relocating and renaming some classes and methods.
Follow this guide to ensure your project is compatible with Nutrient Flutter SDK 4.
Removed APIs
-
The paths
pspdfkit-flutter/lib/widgets/pspdfkit_widget.dart
andpspdfkit-flutter/lib/widgets/pspdfkit_widget_controller.dart
have been removed. Instead, usepackage:pspdfkit_flutter/pspdfkit_pspdfkit.dart
for all imports. -
The optional parameters for
measurementScale
andmeasurementPrecision
have been removed fromPspdfkit.present
. Use themeasurementValueConfigurations
option inPdfConfiguration
instead.
Deprecated APIs
The following APIs have been deprecated in Nutrient Flutter SDK 4.
-
Pspdfkit.setLicenseKey
andPspdfkit.setLicenseKeys
have been deprecated. UsePspdfkit.initialize
instead:
Pspdfkit.initialize( androidLicenseKey: 'YOUR_ANDROID_LICENSE_KEY', iosLicenseKey: 'YOUR_IOS_LICENSE_KEY', webLicenseKey: 'YOUR_WEB_LICENSE_KEY', );
-
The following methods in
PspdfkitWidgetController
have been deprecated in Nutrient Flutter SDK 4. Use the corresponding methods inPdfDocument
instead:
-
setFormFieldValue
— UsePdfDocument.setFormFieldValue
. -
getFormFieldValue
— UsePdfDocument.getFormFieldValue
. -
applyInstantJson
— UsePdfDocument.applyInstantJson
. -
exportInstantJson
— UsePdfDocument.exportInstantJson
. -
addAnnotation
— UsePdfDocument.addAnnotation
. -
removeAnnotation
— UsePdfDocument.removeAnnotation
. -
getAnnotations
— UsePdfDocument.getAnnotations
. -
getAllUnsavedAnnotations
— UsePdfDocument.getAllUnsavedAnnotations
.
-
PspdfkitProcessor
has been deprecated. ThePspdfkitProcessor
class methods can now be statically accessed from thePspdfkit
class.
Other API changes
Some APIs have been moved to new locations and renamed in Nutrient Flutter SDK 4. To ensure your project works correctly, update your code to use a single import statement for all Nutrient Flutter SDK classes and methods:
import 'package:pspdfkit_flutter/pspdfkit_flutter.dart';
Method channel backward compatibility
Nutrient Flutter SDK 4 introduces a new method channel API using Pigeon to bridge native APIs for iOS and Android. However, you can still use the old method channel APIs for backward compatibility. These will be removed in a future release.
To use the old method channel APIs, set the useLegacy
parameter to true
when initializing the SDK:
Pspdfkit.initialize(
useLegacy: true,
);
Updating to Nutrient Flutter SDK 4
To update your project to use Nutrient Flutter SDK 4, follow the steps below.
-
Update your
pubspec.yaml
file to use the latest version of the Nutrient Flutter SDK:
dependencies:
pspdfkit_flutter: ^4.0.0
Changelog
For a complete list of changes in Nutrient Flutter SDK 4, see the changelog.