deepar_flutter_plus 0.0.6
deepar_flutter_plus: ^0.0.6 copied to clipboard
Enhanced DeepAR Flutter SDK with support for loading effects from both assets and file paths
DeepAR Flutter Plus #
An enhanced version of the official DeepAR Flutter SDK that adds support for loading effects from both asset files AND file paths. This makes it possible to load effects that are downloaded or stored anywhere on the device's filesystem, not just from assets.
This plugin is the official SDK for DeepAR. Platforms supported: Android & iOS.
The current version of plugin supports:
- Load effects from both assets and file paths ✨ (New!)
- Live AR previews ✅
- Take screenshots ✅
- Record Videos ✅
- Flip camera ✅
- Toggle Flash ✅
| Support | Android | iOS |
|---|---|---|
| SDK 23+ | iOS 13.0+ |
Installation #
Please visit our developer website to create a project and generate your separate license keys for both platforms.
Once done, please add the latest deepar_flutter_plus dependency to your pubspec.yaml.
Android:
- compileSdkVersion should be 33 or more.
- minSdkVersion should be 23 or more.
- Download the native android dependencies from our downloads section and paste it in your flutter project at
android/app/libs/deepar.aar. - Make sure to
pub clean&flutter pub upgradeto fetch latest working code.
Also add the following permission requests in your AndroidManifest.xml
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CAMERA" />
Ensure to add these rules to proguard-rules.pro else app might crash in release build
-keepclassmembers class ai.deepar.ar.DeepAR { *; }
-keepclassmembers class ai.deepar.ar.core.videotexture.VideoTextureAndroidJava { *; }
-keep class ai.deepar.ar.core.videotexture.VideoTextureAndroidJava
iOS:
- Ensure your app iOS deployment version is 13.0+.
- Do a flutter clean & install pods.
- To handle camera and microphone permissions, please add the following strings to your info.plist.
- Make sure to
pub clean&flutter pub upgradeto fetch latest working code.
<key>NSCameraUsageDescription</key>
<string>---Reason----</string>
<key>NSMicrophoneUsageDescription</key>
<string>---Reason----</string>
- Also add the following to your
Podfilefile:
post_install do |installer|
installer.pods_project.targets.each do |target|
... # Here are some configurations automatically generated by flutter
# Start of the deepar configuration
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## dart: PermissionGroup.microphone
'PERMISSION_MICROPHONE=1',
]
end
# End of the permission_handler configuration
end
end
Flutter:
- Initialize
DeepArControllerby passing in your license keys for both platforms.
final DeepArController _controller = DeepArController();
_controller.initialize(
androidLicenseKey:"---android key---",
iosLicenseKey:"---iOS key---",
resolution: Resolution.high);
- Place the DeepArPreview widget in your widget tree to display the preview.
@override
Widget build(BuildContext context) {
return _controller.isInitialized
? DeepArPreview(_controller)
: const Center(
child: Text("Loading Preview")
);
}
To display the preview in full screen, wrap DeepArPreview with Transform.scale() and use the correct scale factor as per preview area size. More info here.
- Load effects using either asset files or file paths:
// Using asset file
_controller.switchEffect("assets/effects/my_effect.deepar");
// Using file path
_controller.switchEffect("/path/to/effect/file.deepar");
Note: When using file paths, make sure the app has proper permissions to access the file location. For downloaded effects, consider storing them in the app's documents or temporary directory.
- To take a picture, use
takeScreenshot()which returns the picture as file.
final File file = await _controller.takeScreenshot();
- To record a video, please use:
if (_controller.isRecording) {
_controller.stopVideoRecording();
} else {
final File videoFile = _controller.startVideoRecording();
}
For more info, please visit: Developer Help.