Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

docs.flutter.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.

Learn more

Flutter 3.41 is live! Check out theFlutter 3.41 blog post!

Calling JetPack APIs

Use the latest Android APIs from your Dart code

Flutter apps running on Android can always make use of the latest APIs on the first day they are released on Android, no matter what. This page outlines available ways to invoke Android-specific APIs.

Use an existing solution

#

In most scenarios, you can use a plugin (as shown in the next section) to invoke native APIs without writing any custom boilerplate or glue code yourself.

Use a plugin

#

Using a plugin is often the easiest way to access native APIs, regardless of where your Flutter app is running. To use plugins, visitpub.dev and search for the topic you need. Most native features, including accessing common hardware like GPS, the camera, or step counters are supported by robust plugins.

For complete guidance on adding plugins to your Flutter app, see theUsing packages documentation.

Not all native features are supported by plugins, especially immediately after their release. In any scenario where your desired native feature is not covered by a package onpub.dev, continue on to the following sections.

Creating a custom solution

#

Not all scenarios and APIs will be supported by existing solutions; but luckily, you can always add whatever support you need. The next sections describe two different ways to call native code from Dart.

Note

Neither solution below is inherently better or worse than existing plugins, because all plugins use one of the following two options.

The most direct and efficient way to invoke native APIs is by calling the API directly, via FFI. This links your Dart executable to any specified native code at compile-time, allowing you to call it directly from the UI thread through a small amount of glue code. In most cases,ffigen orjnigen are helpful in writing this glue code.

For complete guidance on directly calling native code from your Flutter app, see theFFI documentation.

In the coming months, the Dart team hopes to make this process easier with direct support for calling native APIs using the FFI approach, but without any need for the developer to write glue code.

Add a MethodChannel

#

MethodChannels are an alternate way Flutter apps can invoke arbitrary native code. Unlike the FFI solution described in the previous step, MethodChannels are always asynchronous, which might or might not matter to you, depending on your use case. As with FFI and direct calls to native code, using aMethodChannel requires a small amount of glue code to translate your Dart objects into native objects, and then back again. In most cases,pkg:pigeon is helpful in writing this glue code.

For complete guidance on adding MethodChannels to your Flutter app, see theMethodChannels documentation.

Was this page's content helpful?

Unless stated otherwise, the documentation on this site reflects Flutter 3.38.6. Page last updated on 2025-10-30.View source orreport an issue.


[8]ページ先頭

©2009-2026 Movatter.jp