ar_flutter_plugin 讓開發者能在 Flutter 應用中建立增強實境體驗,支援 iOS 上的 ARKit 與 Android 上的 ARCore。此外,該插件透過允許多個使用者即時互動相同的虛擬內容,實現協作式 AR。插件可無縫整合至 Flutter 專案,並透過統一 API 提供對裝置特定 AR 功能的存取。非常適合用於互動式教育工具、遊戲與沉浸式產品視覺化。
適用情境
互動AR遊戲
虛擬產品預覽
教育類AR應用
協作式AR體驗
基於AR的導航
主要特色
支援 ARKit (iOS) 和 ARCore (Android)
啟用多使用者AR協作
與 Flutter 的簡單整合
即時3D物體放置
跨平台AR開發
適合對象
使用 Flutter 的 AR 開發人員
教育類應用程式創作者
產品可視化應用
遊戲應用
互動敘事平台
使用建議
需要支援AR的相容裝置
在較舊或不受支援的硬體上功能受限
可能需要額外設定才能獲得最佳效能
依賴於平台特定的AR框架
不適用於非AR使用情境
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
ar_flutter_plugin
Flutter Plugin for (collaborative) Augmented Reality - Supports ARKit for iOS and ARCore for Android devices.
Many thanks to Oleksandr Leuschenko for the arkit_flutter_plugin and to Gian Marco Di Francesco for the arcore_flutter_plugin which both served as a great basis and starting point for this project.
Getting Started
Installing
Add the Flutter package to your project by running:
flutter pub add ar_flutter_plugin
Or manually add this to your pubspec.yaml file (and run flutter pub get):
If you have problems with permissions on iOS (e.g. with the camera view not showing up even though camera access is allowed), add this to the podfile of your app's ios directory:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
# Additional configuration options could already be set here
# BEGINNING OF WHAT YOU SHOULD ADD
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## dart: PermissionGroup.photos
'PERMISSION_PHOTOS=1',
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
'PERMISSION_LOCATION=1',
## dart: PermissionGroup.sensors
'PERMISSION_SENSORS=1',
## dart: PermissionGroup.bluetooth
'PERMISSION_BLUETOOTH=1',
# add additional permission groups if required
]
# END OF WHAT YOU SHOULD ADD
end
end
end
Example Applications
To try out the plugin, it is best to have a look at one of the following examples implemented in the Example app:
Example Name
Description
Link to Code
Debug Options
Simple AR scene with toggles to visualize the world origin, feature points and tracked planes
AR scene with buttons to place GLTF objects from the flutter asset folders, GLB objects from the internet, or a GLB object from the app's Documents directory at a given position, rotation and scale. Additional buttons allow to modify scale, position and orientation with regard to the world origin after objects have been placed.
AR Scene in which objects can be placed, uploaded and downloaded, thus creating an interactive AR experience that can be shared between multiple devices. Currently, the example allows to upload the last placed object along with its anchor and download all anchors within a radius of 100m along with all the attached objects (independent of which device originally placed the objects). As sharing the objects is done by using the Google Cloud Anchor Service and Firebase, this requires some additional setup, please read Getting Started with cloud anchors
Similar to the Cloud Anchors example, but contains UI to choose between different models. Rather than being hard-coded, an external database (Firestore) is used to manage the available models. As sharing the objects is done by using the Google Cloud Anchor Service and Firebase, this requires some additional setup, please read Getting Started with cloud anchors. Also make sure that in your Firestore database, the collection "models" contains some entries with the fields "name", "image", and "uri", where "uri" points to the raw file of a model in GLB format