Flutter SDK 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.dartandpspdfkit-flutter/lib/widgets/pspdfkit_widget_controller.darthave been removed. Instead, usepackage:pspdfkit_flutter/pspdfkit_pspdfkit.dartfor all imports. - The optional parameters for
measurementScaleandmeasurementPrecisionhave been removed fromPspdfkit.present. Use themeasurementValueConfigurationsoption inPdfConfigurationinstead.
Deprecated APIs
The following APIs have been deprecated in Nutrient Flutter SDK 4.
Pspdfkit.setLicenseKeyandPspdfkit.setLicenseKeyshave been deprecated. UsePspdfkit.initializeinstead:Pspdfkit.initialize(androidLicenseKey: 'YOUR_ANDROID_LICENSE_KEY',iosLicenseKey: 'YOUR_IOS_LICENSE_KEY',webLicenseKey: 'YOUR_WEB_LICENSE_KEY',);The following methods in
PspdfkitWidgetControllerhave been deprecated in Nutrient Flutter SDK 4. Use the corresponding methods inPdfDocumentinstead:setFormFieldValue— UsePdfDocument.setFormFieldValue.getFormFieldValue— UsePdfDocument.getFormFieldValue.applyInstantJson— UsePdfDocument.applyInstantJson.exportInstantJson— UsePdfDocument.exportInstantJson.addAnnotation— UsePdfDocument.addAnnotation.removeAnnotation— UsePdfDocument.removeAnnotation.getAnnotations— UsePdfDocument.getAnnotations.getAllUnsavedAnnotations— UsePdfDocument.getAllUnsavedAnnotations.
PspdfkitProcessorhas been deprecated. ThePspdfkitProcessorclass methods can now be statically accessed from thePspdfkitclass.
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.yamlfile 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.