Skip to content

Add Native interop documentation section (Pigeon, FFIgen, JNIgen, dart:ffi) - #13995

Merged
lamek merged 16 commits into
flutter:mainfrom
lamek:native-interop-eap
Nov 3, 2026
Merged

lamek merged 16 commits into
flutter:mainfrom
lamek:native-interop-eap

Conversation

@lamek

@lamek lamek commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Description of what this PR is changing or adding, and why:

Adds the new top-level Native interop documentation section (/interop) for the upcoming Flutter 3.50 / Native Interop GA release:

  • Overview (/interop): Decision tree (Mermaid flowchart and step-by-step walkthrough), packaging options, tool comparison matrix, and 3-layer interop architecture.
  • Pigeon (/interop/pigeon): Covers Pigeon with native interop (direct FFI on iOS/macOS and JNI on Android) and Pigeon with platform channels, developer workflow, examples, and constraints.
  • FFIgen (/interop/ffigen): Covers generating C, Objective-C, and Swift bindings with tool/ffigen.dart, developer workflow, examples, and platform/runtime considerations.
  • JNIgen (/interop/jnigen): Covers generating Java and Kotlin bindings on Android with tool/jnigen.dart, developer workflow, examples, and threading/reference lifecycle considerations.
  • dart:ffi (/interop/dart-ffi): Covers native memory allocation, data conversion (package:ffi), and isolate concurrency (Isolate.run).
  • Bind to native code (/interop/bind-native-code): Moved from /platform-integration/bind-native-code with a 301 redirect in firebase.json.
  • Platform channels (/platform-integration/platform-channels): Updated to link to the new Native interop overview and dedicated Pigeon guide.
  • Sidenav (sites/docs/src/data/sidenav/default.yml): Adds the top-level Native interop section above Platform integration.

Issues fixed by this PR (if any):

PRs or commits this PR depends on (if any):

N/A (Draft for early review and staging preview before Flutter 3.50 release)

Presubmit checklist

  • If you are unwilling, or unable, to sign the CLA, even for a tiny, one-word PR, please file an issue instead of a PR.
  • If this PR is not meant to land until a future stable release, mark it as draft with an explanation.
  • This PR follows the Google Developer Documentation Style Guidelines—for example, it doesn't use i.e. or e.g., and it avoids I and we (first-person pronouns).
  • This PR uses semantic line breaks
    of 80 characters or fewer.

- Add Native interop landing page with decision tree and layers guide
- Add Pigeon guide covering platform channels and native bindings modes
- Add FFIgen guide covering Apple frameworks, C-ABI, and developer flow
- Add dart:ffi guide for native memory allocation and concurrency
- Move bind-native-code into platform-integration/interop/
- Add JNIgen guide for Java/Kotlin and Android bindings
- Update platform-channels to focus on manual message passing
- Update sidenav default.yml with new Native interop section
- Update firebase.json with 301 redirect for bind-native-code

TAG=agy
CONV=a76ca369-bcbf-4f8a-822b-b2d6bdd86f54
- Restore exact text, structure, and headings from the Google Doc
- Remove extraneous code examples from developer flow sections

TAG=agy
CONV=a76ca369-bcbf-4f8a-822b-b2d6bdd86f54
@flutter-website-bot

flutter-website-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

@parlough

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive "Native interop" documentation section, adding new guides for dart:ffi, FFIgen, JNIgen, and Pigeon, along with an overview page to help developers choose the right interop solution. It also updates existing platform integration docs, sidebar navigation, and redirects to point to these new pages. A review comment points out an incorrect API reference in the JNIgen guide, suggesting the use of PlatformDispatcher.instance.scheduleOnPlatformThread instead of runOnPlatformThread.

@sfshaza2 sfshaza2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some quibbles but, overall, a great addition to the site! I like the decision graph and would be hesitant to clobber it. I also like the table comparing the approaches.

@sfshaza2 sfshaza2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, once my feedback is incorporated. I'll go ahead and approve, but I'd like approval from a SME. thx! Overall, this looks great!

@tarrinneal tarrinneal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple little clarifications

Comment thread sites/docs/src/content/interop/index.md Resolved
@lamek
lamek marked this pull request as ready for review October 29, 2026 01:38
@lamek
lamek requested a review from a team as a code owner October 29, 2026 01:38

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request restructures the documentation by introducing a new 'Native interop' section, adding dedicated guides for dart:ffi, FFIgen, JNIgen, and Pigeon, and updating existing files to link to these new paths. Feedback on these changes includes a suggestion to flatten the sidebar navigation under 'Native interop' to make dart:ffi and 'Bind to native code' more discoverable, as well as a correction in the FFIgen guide to use .cast<T>() instead of .as() for casting Objective-C objects to avoid compilation errors.

Comment thread sites/docs/src/data/sidenav/default.yml Resolved

@mariamhas mariamhas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments that need to be addressed before this is published

Comment thread sites/docs/src/content/interop/index.md Resolved
Comment thread sites/docs/src/content/interop/index.md Resolved
Comment thread sites/docs/src/content/interop/index.md Resolved
Comment thread sites/docs/src/content/interop/index.md Resolved

@goderbauer goderbauer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's still outdated verbiage in one places on the website, e.g.
https://docs.flutter.dev/platform-integration/android/call-jetpack-apis says:

In the coming months, the Dart team hopes to make this process easier with direct support for calling native APIs using the FFI approach...

Can we update that as well as part of this update?

@lamek

lamek commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@goderbauer Thanks for spotting the outdated verbiage. I made that change, and did a scan to update a few more outdated instances.

and enables native memory interop.

## When to use `dart:ffi`
## When to use `dart:ffi` and `package:ffi`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need this section at all now? It's a bit redundant with the "## Core tools: dart:ffi and package:ffi" section below, and that section is much clearer.

@lamek
lamek merged commit 10b356a into flutter:main Nov 3, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants