---
title: "How do I send data from iOS to Dart in Flutter?"
canonical_url: "https://www.nutrient.io/guides/flutter/knowledge-base/flutter-sending-data-to-dart/"
md_url: "https://www.nutrient.io/guides/flutter/knowledge-base/flutter-sending-data-to-dart.md"
last_updated: "2026-05-23T00:08:18.091Z"
description: "To send data from the iOS side (Objective-C) back to the Flutter side (Dart), use FlutterMethodChannel. In our Flutter example project."
---

To send data from the iOS side (Objective-C) back to the Flutter side (Dart), use `FlutterMethodChannel`. In our [Flutter example](https://www.nutrient.io/sdk/flutter/getting-started.md) project, there are already two callbacks: `pdfViewControllerWillDismiss` and `pdfViewControllerDidDismiss`. However, these callbacks don’t send any data back to the Flutter side. To send some data back, you can use the channel’s arguments. Implement this by modifying the [Flutter example](https://www.nutrient.io/sdk/flutter/getting-started.md). If you don’t already have it, clone or download the Flutter project, as you’ll make the changes there.

In this example, you’ll implement a callback to notify the Dart side whenever the user scrolls a document and changes the document’s spread index. In this example, you’ll use the [`PSPDFDocumentViewControllerSpreadIndexDidChangeNotification`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/foundation/nsnotification/name/pspdfdocumentviewcontrollerspreadindexdidchange) notification provided by Nutrient, but you can use any sort of callback here, such as a delegate method. For the same spread index change event, you can also use [this method](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfdocumentviewcontrollerdelegate/documentviewcontroller(_:didchangespreadindex:)) of `PSPDFDocumentViewControllerDelegate`.

Here’s a list of changes you’ll need to make to the example:

1. In [`PspdfkitPlugin.m`](https://github.com/PSPDFKit/pspdfkit-flutter/blob/master/ios/Classes/PspdfkitPlugin.m), in the [`handleMethodCall`](https://github.com/PSPDFKit/pspdfkit-flutter/blob/ef947dfebb16005baea9de096857922310073fc0/ios/Classes/PspdfkitPlugin.m#L34) method, right after you call [`setLicenseKey`](https://github.com/PSPDFKit/pspdfkit-flutter/blob/ef947dfebb16005baea9de096857922310073fc0/ios/Classes/PspdfkitPlugin.m#L37), you can start listening to the `spreadIndex` change notifications like so:

   ```objc

   [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(spreadIndexDidChange:) name:PSPDFDocumentViewControllerSpreadIndexDidChangeNotification object:nil];
   ```

   Then, you can implement the `spreadIndexDidChange` method in the same file like this:

   ```objc

   - (void)spreadIndexDidChange:(NSNotification *)notification {
       long oldPageIndex = [notification.userInfo[@"PSPDFDocumentViewControllerOldSpreadIndexKey"] longValue];
       long currentPageIndex = [notification.userInfo[@"PSPDFDocumentViewControllerSpreadIndexKey"] longValue];
       NSMutableDictionary *pageIndices = @{@"oldPageIndex": @(oldPageIndex), @"currentPageIndex": @(currentPageIndex)};
       [channel invokeMethod:@"spreadIndexDidChange" arguments:pageIndices];
   }
   ```

2. In the [`lib/pspdfkit.dart`](https://github.com/PSPDFKit/pspdfkit-flutter/blob/master/lib/nutrient_flutter.dart) file, you’ll need to add another callback function right after [`pdfViewControllerDidDismiss`](https://github.com/PSPDFKit/pspdfkit-flutter/blob/ef947dfebb16005baea9de096857922310073fc0/lib/src/main.dart#L138):

   ```dart

   static void Function(dynamic) spreadIndexDidChange;
   ```

   Then, add a new case to handle it in the [`_platformCallHandler`](https://github.com/PSPDFKit/pspdfkit-flutter/blob/ef947dfebb16005baea9de096857922310073fc0/lib/src/main.dart#L140) function:

   ```dart

   case 'spreadIndexDidChange':
       spreadIndexDidChange(call.arguments);
       break;
   ```

   Here, you’re passing along the call arguments that you’ll use in your example.

3. Finally, in [`example/lib/main.dart`](https://github.com/PSPDFKit/pspdfkit-flutter/blob/master/example/lib/main.dart), you can use these arguments by creating a handler function like this:

   ```dart

   void spreadIndexDidChangeHandler(dynamic arguments) {
       print(arguments);
   }
   ```

The last piece of the puzzle is to connect this function you created with the plugin. You can do that in the widget’s `build` method after setting the other handlers (for `pdfViewControllerWillDismiss` and `pdfViewControllerDidDismiss`):

```dart

Pspdfkit.spreadIndexDidChange = (dynamic arguments) => spreadIndexDidChangeHandler(arguments);

```

After editing the example like shown here, run the Flutter example by following the [steps here](https://github.com/PSPDFKit/pspdfkit-flutter/tree/master/example). You’ll see that when changing pages, the new and old page indexes will be printed from the Dart side. You can follow this pattern for all different sorts of callbacks and update the plugin to adapt to your use case.
---

## Related pages

- [Flutter Appearance Customization](/guides/flutter/knowledge-base/flutter-appearance-customization.md)

