The Flutter imgly_editor
plugin is built on top of the native Android and iOS UI implementation and has no dedicated Flutter UI.
However, you still have access to the same customization options as for iOS and Android.
To use them you need to configure them natively for both platforms.
Native Interfaces
In order to allow intuitive and easily accessible native customization of the editors, we provide dedicated interfaces and convenience functions for both iOS and Android.
The editor that is opened via the IMGLYEditor.openEditor()
function can be completely customized and exchanged.
For this to work you can use the IMGLYEditorPlugin.builderClosure
which provides an optional EditorPreset
and metadata
with which you can provide any prebuilt or custom editor view. The metadata
parameter of the openEditor
function can be utilized
to provide customization details from the Flutter side of your app to the native side:
iOS
On iOS, we provide fallback functions for our default editors via:
EditorBuilder.design()
EditorBuilder.apparel()
EditorBuilder.photo()
EditorBuilder.video()
EditorBuilder.postcard()
In case you want a completely custom UI, you can use the EditorBuilder.custom
function that allows you to return a custom View
based on a given EditorConfig
, an EditorPreset
, metadata
and an EditorBuilderResult
:
1. Import the dependencies:
import androidx.compose.runtime.Composableimport ly.img.camera.core.CameraLayoutModeimport ly.img.camera.core.CameraModeimport ly.img.camera.core.CameraResultimport ly.img.camera.core.CaptureVideoimport ly.img.camera.flutter.plugin.IMGLYCameraPluginimport ly.img.editor.flutter.plugin.IMGLYEditorPluginimport ly.img.editor.flutter.plugin.builder.EditorBuilderimport ly.img.editor.flutter.plugin.builder.EditorBuilderResultimport ly.img.editor.flutter.plugin.model.EditorSettings
2. Assign your custom editor:
IMGLYEditorPlugin.builderClosure = { _, metadata -> if (metadata?.get("custom") == true) { EditorBuilder.custom { settings, _, _, result, onClose -> @Composable { CustomEditor(settings, result, onClose) } } } else { EditorBuilder.design() }}
Further, we provide convenience extensions both for the OnCreate
and OnExport
callbacks to reduce the amount of code you need to write. For a detailed example, please take a look at our showcases app.
Android
On Android, we provide fallback functions for our default editors via
EditorBuilder.design()
EditorBuilder.apparel()
EditorBuilder.photo()
EditorBuilder.postcard()
.
In case you want a completely custom UI, you can use the EditorBuilder.custom
function that allows you to return a custom @Composable
function based on a given EditorConfig
, an EditorPreset
, metadata
and an EditorBuilderResult
:
1. Update the android/app/build.gradle
file and add the following:
android { (...) kotlinOptions { jvmTarget = "1.8" }
buildFeatures { compose true }
composeOptions { kotlinCompilerExtensionVersion = "1.5.3" }}
dependencies { implementation "ly.img:editor:1.30.0" implementation(platform("androidx.compose:compose-bom:2023.05.01")) implementation "androidx.activity:activity-compose:1.8.2"}
2. Import the dependencies:
import androidx.compose.runtime.Composableimport ly.img.camera.core.CameraLayoutModeimport ly.img.camera.core.CameraModeimport ly.img.camera.core.CameraResultimport ly.img.camera.core.CaptureVideoimport ly.img.camera.flutter.plugin.IMGLYCameraPluginimport ly.img.editor.flutter.plugin.IMGLYEditorPluginimport ly.img.editor.flutter.plugin.builder.EditorBuilderimport ly.img.editor.flutter.plugin.builder.EditorBuilderResultimport ly.img.editor.flutter.plugin.model.EditorSettings
3. Assign your custom editor:
IMGLYEditorPlugin.builderClosure = { _, metadata -> if (metadata?.get("custom") == true) { EditorBuilder.custom { settings, _, _, result, onClose -> @Composable { CustomEditor(settings, result, onClose) } } } else { EditorBuilder.design() }}
Further, we provide a class called EditorDefaults
which contains convenience methods for both the OnCreate
and OnExport
callbacks to reduce the amount of code you need to write. For a detailed example, please take a look here.