Flutter SDK 6.1 migration guide
Nutrient Flutter SDK 6.1 updates to Nutrient Android SDK 12.1.0, Nutrient iOS SDK 27.1.0, and Nutrient Web SDK 1.24.0. This guide covers the changes you need to make when you upgrade from 6.0. If you’re upgrading from 5.x, follow the Flutter SDK 6 migration guide first.
Update the dependencies
Update the Nutrient packages in your pubspec.yaml file, and then run flutter pub get. Nutrient Flutter SDK 6.1.0 uses version 2.1.0 of the federated platform packages:
dependencies: nutrient_flutter: ^6.1.0 nutrient_flutter_android: ^2.1.0 nutrient_flutter_ios: ^2.1.0 nutrient_flutter_web: ^2.1.0Keep only the platform packages your app already depends on.
Android
The Android changes cover the build toolchain, manifest initialization, toolbar colors, and platform adapters that use the JNI bindings.
Set compile SDK 37.1
Nutrient Flutter SDK 6.1 requires compile SDK 37.1. Set compileSdk and compileSdkMinor explicitly in your app-level android/app/build.gradle.kts (or android/app/build.gradle) file, because flutter.compileSdkVersion still reports 36:
android { compileSdk = 37 compileSdkMinor = 1}Update Android Gradle Plugin, Gradle, and Kotlin
Nutrient Flutter SDK 6.1 requires Android Gradle Plugin 9.2 or later, Gradle 9.4.1 or later, and Kotlin Gradle plugin 2.3 or later. Projects created with Flutter 3.44 start on older Android Gradle Plugin and Gradle versions, so update both. Nutrient Android SDK 12.1.0 is built with Kotlin 2.4. Kotlin Gradle plugin 2.2 and earlier can’t read its metadata, so the build fails with “Module was compiled with an incompatible version of Kotlin.”
In the plugins block of android/settings.gradle.kts (or android/settings.gradle), set the Android Gradle Plugin version and the Kotlin Gradle plugin version if it’s older than 2.3. Keep the other plugins as they are:
plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" id("com.android.application") version "9.2.1" apply false id("org.jetbrains.kotlin.android") version "2.3.20" apply false}Set the Gradle version in distributionUrl in android/gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-all.zipRecent Kotlin Gradle plugin versions replace the kotlinOptions block with compilerOptions. If your app-level Gradle file still sets the Kotlin JVM target in a kotlinOptions block inside android, replace it with a top-level kotlin block:
kotlin { compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 }}Remove automatic initialization from your manifest
Earlier versions of the getting started guide and the Flutter SDK 6 migration guide told you to set nutrient_automatic_initialize to true in android/app/src/main/AndroidManifest.xml. If your manifest has this <meta-data> element, delete it:
<meta-data android:name="nutrient_automatic_initialize" android:value="true" tools:replace="android:value" />nutrient_flutter_android turns automatic initialization off so that Nutrient.initialize() initializes the SDK and applies your license key. With automatic initialization on, the SDK rejects the license key, and Nutrient.initialize() throws. This also applies to Nutrient Flutter SDK 6.0. If nothing else in your manifest uses the tools: prefix, you can also remove the xmlns:tools attribute from the <manifest> element.
Move toolbar colors to the Android theme
On Android, the deprecated NutrientView and PspdfkitWidget widgets no longer apply the ThemeConfiguration.toolbar and ThemeConfiguration.annotationToolbar colors, apart from toolbar.statusBarColor. The viewer logs a warning that names the ignored colors. Nutrient.present() isn’t affected, because it never applied these colors.
The toolbars take their colors from the Android theme instead. Define a theme that sets the pspdf__mainToolbarStyle and pspdf__contextualToolbarStyle attributes, as described in the Android appearance styling guide, and pass its name to PdfConfiguration.androidDefaultThemeResource.
Update platform adapters that use the JNI bindings
If your Android platform adapter calls the Nutrient Android SDK through the Java Native Interface (JNI) bindings, the bindings are now generated against Nutrient Android SDK 12.1.0. Bindings for the APIs that Nutrient Android SDK 12.0.0 and 12.1.0 removed are gone:
- The RxJava and blocking
AnnotationProvidermethods. UseAnnotationProviderBlockingfromnutrient_flutter_androidinstead. For form lookups, useFormProviderBlocking. - The view-based toolbar and menu APIs, such as
ToolbarCoordinatorLayoutand its contextual toolbar listeners,ContextualToolbar,AnnotationToolbar, andOnMenuItemsGenerateListener. The Nutrient Android SDK 12 migration guide describes their replacements.
iOS
Nutrient iOS SDK 27.1.0 requires Xcode 27 or later. Build your iOS app with Xcode 27. The iOS deployment target stays at iOS 17.0.
Apps built with Xcode 27 must use the UIScene lifecycle, or they fail to launch on iOS 27. If your app’s ios/Runner/Info.plist file doesn’t declare UIApplicationSceneManifest, run flutter build ios or flutter run once. If your AppDelegate and Info.plist files are unchanged from the Flutter template, the Flutter tool migrates them for you. Otherwise, it prints a warning that UIScene support will soon be required, and you need to follow Flutter’s UIScene migration(opens in a new tab) guide. Building in Xcode alone doesn’t run this migration.
Flutter declares an iOS 13.0 deployment target for its Flutter pod, which Xcode 27 rejects. In your ios/Podfile file, let pods with a lower deployment target inherit the target from the Podfile’s platform setting. Add the following to the post_install block, after flutter_additional_ios_build_settings(target):
post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) target.build_configurations.each do |config| if Gem::Version.new(config.build_settings["IPHONEOS_DEPLOYMENT_TARGET"] || "0") < Gem::Version.new("17.0") config.build_settings.delete("IPHONEOS_DEPLOYMENT_TARGET") end end endendThen run pod install in the ios directory.
Web
The Web changes cover the Web SDK version, save failures, and platform adapters that use the JavaScript bindings.
Load Nutrient Web SDK 1.24.0
Update the <script> tag in your web app’s index.html file to load Nutrient Web SDK 1.24.0:
<script src="https://cdn.cloud.nutrient.io/pspdfkit-web@1.24.0/nutrient-viewer.js"></script>If you host the Web SDK files yourself, replace them with the files from the Nutrient Web SDK 1.24.0 archive.
Handle save failures
On the web, saving now fails when Document Engine refuses a change, where it previously succeeded:
- With
NutrientDocumentViewand the bindings API,save()throws. Catch the error where your app saves documents. - With the deprecated
NutrientView,save()on its document returnsfalse, andsave()on itsNutrientViewControllerthrows. Check the returned value or catch the error, depending on which one your app calls.
Update platform adapters that use the JavaScript bindings
If your web platform adapter uses the dart:js_interop bindings directly, they’re now generated from Nutrient Web SDK 1.24.0, and some names and signatures changed. The main changes are:
- The Web SDK’s static functions are static methods of
NutrientViewer— for example,NutrientViewer.load(). - Namespace members no longer have a namespace prefix, so use
Rectinstead ofGeometry_Rect. package:nutrient_flutter_web/nutrient_flutter_web.dartno longer exports the bindings’LocaleandAlignment, which clash with Flutter’s. For the full bindings, importpackage:nutrient_flutter_web/nutrient_web_bindings.dartwith a prefix.
For the full list of binding changes, refer to the nutrient_flutter_web changelog(opens in a new tab).
Changelog
For the full list of changes in Nutrient Flutter SDK 6.1, refer to the changelog.