Search Docs
Loading...
Skip to content

Customization

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 imgly_camera
import imgly_editor
import SwiftUI

Leave out import imgly_camera if your app does not use the imgly_camera plugin.

2. Assign your custom editor:#

IMGLYEditorPlugin.builderClosure = { _, metadata in
// Make decisions based on your own metadata.
if metadata?["use_custom_editor"] as? Bool == true {
// Return your custom editor.
EditorBuilder.custom { settings, _, _, result in
CustomEditor(settings: settings, result: result)
}
} else {
// Return a custom or prebuilt editor.
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. Turn on Jetpack Compose in your app module:#

The custom editor is a @Composable function, so your app module needs Jetpack Compose. The imgly_editor plugin brings the editor and Compose libraries, so you add no Gradle dependency.

First, declare the Compose Compiler Gradle plugin in android/settings.gradle.kts, as described in Declare the Compose Compiler Plugin. Then apply it in android/app/build.gradle.kts and turn on Compose. Add only the lines marked +, and keep the other lines of your file:

android/app/build.gradle.kts
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.plugin.compose")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
android {
(...)
buildFeatures {
compose = true
}
}

The version of the Compose Compiler plugin must match the Kotlin version that your build uses. To see it, run ./gradlew :app:dependencies --configuration kotlinCompilerClasspath in android/ and read the kotlin-compiler-embeddable version.

Kotlin 1.9.10, which Flutter before 3.44 still accepts, has no Compose Compiler plugin. Use the composeOptions block inside the android section instead of both plugin lines, and keep compose = true:

android/app/build.gradle.kts
android {
(...)
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.3"
}
}

If your project uses Groovy build files (settings.gradle, build.gradle), write id "org.jetbrains.kotlin.plugin.compose" and compose true instead.

2. Import the dependencies:#

import androidx.compose.runtime.Composable
import ly.img.camera.core.CameraLayoutMode
import ly.img.camera.core.CameraMode
import ly.img.camera.core.CameraResult
import ly.img.camera.core.CaptureMedia
import ly.img.camera.core.videos
import ly.img.camera.flutter.plugin.IMGLYCameraPlugin
import ly.img.editor.flutter.plugin.IMGLYEditorPlugin
import ly.img.editor.flutter.plugin.builder.EditorBuilder
import ly.img.editor.flutter.plugin.builder.EditorBuilderResult
import ly.img.editor.flutter.plugin.model.EditorSettings

Leave out the ly.img.camera imports if your app does not use the imgly_camera plugin.

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.

Add a Plugin#

A plugin adds a feature to the native editor, such as background removal or voice isolation. The plugins overview for iOS and Android lists the plugins, and each plugin’s guide gives its dependency, its import and its options. In a Flutter app, two things differ:

  • The dependency uses exactly the version of imgly_editor. Add the Swift package to the Runner target in ios/Runner.xcworkspace, and the Android artifact to android/app/build.gradle. The Android plugin needs the Compose setup from step 1 of the Android section above.
  • The plugin goes into the editor that your builderClosure returns, after the editor configuration.

On iOS, for background removal:

BackgroundRemovalPlugin()

On Android:

.then(::IMGLYBackgroundRemovalPlugin)

The Plugins section of our showcases app opens background removal and voice isolation: see the editors in AppDelegate.swift and MainActivity.kt.

Troubleshooting: with CocoaPods (Flutter before 3.44, or Swift Package Manager turned off), add the plugin’s pod, such as IMGLYPluginBackgroundRemoval, to the Runner target instead of the Swift package. The showcases README shows the Podfile.

Page Format Define default page size, orientation, and other format settings for your design canvas.
Crop Presets Define crop presets settings for your design.
Force Crop Define crop presets settings for your design.
Movement Constraints Restrict how far blocks can be dragged outside the page during user interactions in CE.SDK.
Drag & Drop Swap the images of two blocks by dragging, drop assets onto the canvas, and place a new block where the user released it.
Color Palette Customize the color palette available to users for consistent branding and styling.
Disable or Enable Features Control which editor features are available to users by enabling or disabling them.
Rearrange Buttons Learn how to reorder buttons and components in CE.SDK's navigation bar, canvas menu, canvas bar, dock, and inspector bar using the Ordering APIs.
Navigation Bar Show, hide, position, or customize the editor’s navigation bar to match your app layout.
Dock Configure the dock area to show or hide tools, panels, or quick access actions.
Panel Show or hide side panels to focus the user interface on what matters most for your use case.
Inspector Bar Customize the inspector bar for editing properties like position, color, and size.
Canvas Menu Control visibility and options in the canvas context menu.
Video Timeline Customize the video timeline's track visibility, transition controls, height, and controls bar.
Hide Elements Learn how to hide and show UI elements in CE.SDK using the Features API, ordering APIs, and panel management across different platforms.