Skip to main content

Flutter for Android

Installation Steps

See DeepAR SDK for Android to create a project and generate your separate license key.

Once done, please add the latest deepar_flutter dependency to your pubspec.yaml.

Please download the native Android dependencies from our Downloads section and save it at two locations:

1/ In your flutter project as android/app/libs/deepar.aar.

2/ In the root of your Flutter environment directory, navigate to deepar_flutter pub-cache folder and create a new libs folder and place the deepar.aar file as following:

  • ~/.pub-cache/hosted/pub.dartlang.org/deepar_flutter-<plugin-version>/android/libs/deepar.aar (Linux/ Mac)

  • %LOCALAPPDATA%\Pub\Cache\hosted\pub.dartlang.org\deepar_flutter-<plugin-version>\android\libs\deepar.aar(Windows)

  • compileSdkVersion should be 33 or more

  • minSdkVersion should be 21 or more

3/ Also add the following permission requests in your AndroidManifest.xml

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="Manifest.permission.CAPTURE_AUDIO_OUTPUT" />

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();
}