ar_flutter_plugin_2 是原始 AR Flutter 插件的維護分支,專為在 Android 和 iOS 上的 Flutter 應用中建立增強實境體驗而設計。它透過持續支援與現代 Flutter 版本的相容性,解決了原始插件缺乏更新的問題。該套件讓開發者能夠將 3D 模型渲染和基於相機的互動功能整合至其應用程式中。它利用原生 AR 框架(如 Android 的 ARCore 和 iOS 的 ARKit),確保流暢的效能並存取裝置特定的 AR 功能。
適用情境
建構AR產品預覽
建立互動式教育應用程式
使用3D物件開發遊戲體驗
在零售應用中啟用虛擬試穿
主要特色
支援 ARCore 和 ARKit
即時3D模型渲染
AR 場景的相機整合
定期更新和維護
跨平台AR開發
適合對象
尋求AR功能的Flutter開發者
在真實環境中需要3D物體放置的應用程式
需要最新AR支援的專案
使用建議
需要支援AR的相容裝置
僅限 Android 和 iOS 平台
可能需要額外設定以實現複雜的AR互動
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
ar_flutter_plugin_2
This version is a direct adaptation of the original ar_flutter_plugin (https://pub.dev/packages/ar_flutter_plugin),
migrating the Android component from Sceneform to sceneview_android, enabling the use of animated models.
This fork was created because the original plugin had not been updated since 2022.
➡ Changes include an update to the AR Core endpoint, a gradle upgrade, and compatibility with FlutterFlow.
➡ Migration has been done from sceneform to sceneview_android with the help of Cursor (Ai editor) so maybe some parts are not fully correct (Any contribution is welcome)
To prevent your application from crashing when launching augmented reality on iOS, you need to add the following permission to the Info.plist file (located under ios/Runner) :
<key>NSCameraUsageDescription</key>
<string>This application requires camera access for augmented reality functionality.</string>
If you're using FlutterFlow, go to "App Settings" > "Permissions"
For the "Camera" line, toggle the switch to "On" and add the description : "This application requires access to the camera to enable augmented reality features."
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
In FlutterFlow :
Unfortunately, at this stage, it is not possible to carry out the procedure above within FlutterFlow.
Therefore, it is necessary to publish your project with github and make the modifications manually. And then publish wih Github selected in Deployment Sources : FlutterFlow Publish from Github
Example Applications
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