Flutter for iOS
Installation Steps
See DeepAR SDK for iOS to create a project and generate your separate license key.
Once done, please add the latest deepar_flutter
dependency to your pubspec.yaml.
1/ Ensure your app iOS deployment version is 13.0+.
2/ Download the DeepAR iOS binaries from our Downloads here.
3/ Copy the DeepAR.xcframework
file from /lib
folder of the downloaded file and paste as /ios/DeepAR.xcframework
in the plugin's directory. Pub-cache folder can be found in the following directories, depending on your operating system:
Linux / Mac:
~/.pub-cache/hosted/pub.dartlang.org/deepar_flutter-<plugin-version>/android/libs/deepar.aar
Windows:
%LOCALAPPDATA%\Pub\Cache\hosted\pub.dartlang.org\deepar_flutter-<plugin-version>\android\libs\deepar.aar
4/ Do a Flutter clean & install pods again.
5/ To handle camera and microphone permissions, please add the following strings to your info.plist.
<key>NSCameraUsageDescription</key>
<string>---Reason----</string>
<key>NSMicrophoneUsageDescription</key>
<string>---Reason----</string>
6/ Also add the following to your Podfile file:
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 Installation Steps
1/ Initialize DeepArController
by passing in your license keys for both platforms.
<final DeepArController _controller = DeepArController();
_controller.initialize(
androidLicenseKey:"---android key---",
iosLicenseKey:"---iOS key---",
resolution: Resolution.high); />
2/ Place the DeepArPreview widget in your widget tree to display the preview.
Widget build(BuildContext context) {
return _controller.isInitialized
? DeepArPreview(_controller)
: const Center(
child: Text("Loading Preview")
);
}
3/ Load an effect of your choice by passing the asset file to it in switchPreview
.
_controller.switchEffect(effect);
4/ To take a picture, use takeScreenshot()
which return the picture as file.
final File file = await _controller.takeScreenshot();
5/ To record a video use the following:
if (_controller.isRecording) {
_controller.stopVideoRecording();
} else {
final File videoFile = _controller.startVideoRecording();
}