利用 Apple 系统 API 与框架
了解提供与 Apple 框架等价功能的 Flutter 插件。
若你来自 iOS 开发背景,可能需要找到与 Apple 系统库能力相当的 Flutter 插件,例如访问设备硬件或与 HealthKit 等特定框架交互。
要了解 SwiftUI 框架与 Flutter 的对比,请参阅 面向 SwiftUI 开发者的 Flutter 指南。
Flutter 插件简介
#Dart 将包含平台相关代码的库称为 plugins(plugin package 的缩写)。使用 Flutter 开发应用时,通过 plugins 与系统库交互。
在 Dart 代码中,你使用插件的 Dart API 调用所用系统库中的原生代码。也就是说,你只需编写调用 Dart API 的代码,API 会在插件支持的所有平台上生效。
有关插件的更多信息,请参阅 使用 package。本页虽链接了一些常用插件,你仍可在 pub.dev 上找到数千个插件及示例。下表不代表对任何特定插件的背书。若找不到满足需求的 package,可自行创建或在项目中直接使用 platform channel。详情请参阅 编写平台相关代码。
向项目添加插件
#要在原生项目中使用 Apple 框架,请将其导入 Swift 或 Objective-C 文件。
要添加 Flutter 插件,在项目根目录运行 flutter pub add package_name。这会将依赖写入 pubspec.yaml。添加依赖后,在 Dart 文件中
import 该 package。
你可能需要修改应用设置或初始化逻辑;如有需要,pub.dev 上该 package 的「Readme」页面会提供说明。
Flutter 插件与 Apple 框架
#Photos
、
PhotosUI
框架及
UIImagePickerController
的
PhotoKit
|
image_picker |
|
.camera sourceType 的 UIImagePickerController |
image_picker |
|
AVFoundation |
camera |
|
StoreKit |
in_app_purchase
1
in_app_purchase
1
|
|
PassKit |
pay
2
pay
2
|
|
UserNotifications |
firebase_messaging
3
firebase_messaging
3
|
|
CoreLocation |
geolocator |
|
CoreMotion |
sensors_plus |
|
URLSession |
http |
|
@AppStorage 属性包装器与 NSUserDefaults |
shared_preferences
|
|
CoreData 或 SQLite |
sqflite |
|
HealthKit |
health |
|
CoreML |
google_ml_kit
5
google_ml_kit
5
|
|
VisionKit |
google_ml_kit
5
google_ml_kit
5
|
|
Speech |
speech_to_text |
|
ARKit |
ar_flutter_plugin
|
|
WeatherKit |
weather
6
weather
6
|
|
Contacts |
contacts_service |
|
UIApplicationShortcutItem |
quick_actions |
|
CoreSpotlight |
flutter_core_spotlight
|
|
WidgetKit |
home_widget |
|
AppIntents |
intelligence |
-
Supports both Google Play Store on Android and Apple App Store on iOS. 同时支持 Android 的 Google Play 商店与 iOS 的 Apple App Store。 ↩ ↩2
-
Adds Google Pay payments on Android and Apple Pay payments on iOS. 在 Android 上添加 Google Pay,在 iOS 上添加 Apple Pay。 ↩ ↩2
-
Uses Firebase Cloud Messaging and integrates with APNs. 使用 Firebase Cloud Messaging 并与 APNs 集成。 ↩ ↩2
-
Includes sensors like accelerometer, gyroscope, etc. 包括加速度计、陀螺仪等传感器。 ↩
-
Uses Google's ML Kit and supports various features like text recognition, face detection, image labeling, landmark recognition, and barcode scanning. You can also create a custom model with Firebase. To learn more, see Use a custom TensorFlow Lite model with Flutter. 使用 Google ML Kit,支持文字识别、人脸检测、图像标注、地标识别、条码扫描等。也可通过 Firebase 创建自定义模型。详情请参阅 在 Flutter 中使用自定义 TensorFlow Lite 模型。 ↩ ↩2 ↩3 ↩4
-
Uses the OpenWeatherMap API. Other packages exist that can pull from different weather APIs. 使用 OpenWeatherMap API。另有 package 可从其他天气 API 拉取数据。 ↩ ↩2
除非另有说明,本文档之所提及适用于 Flutter 3.44.0 版本。本页面最后更新时间:2026-06-04。查看文档源码 或者 为本页面内容提出建议。