This guide demonstrates how to quickly integrate iOS Photo Editor SDK into your Flutter project.
The main part of an integration and customization is implemented in ios
directory
in your Flutter project using native iOS development process.
Once complete you will be able to launch photo editor in your Flutter project.
Add iOS Photo Editor SDK dependencies to your Podfile
# Photo Editor
pod 'BanubaPhotoEditorSDK', '1.2.3'
Create new Swift class PhotoEditorModule in your project for initializing and customizing Photo Editor SDK features.
Flutter platform channels approach is used for communication between Flutter and iOS.
Set up channel message handler in your AppDelegate to listen to calls from Flutter.
let binaryMessenger = controller as? FlutterBinaryMessenger {
let channel = FlutterMethodChannel(
name: AppDelegate.channelName,
binaryMessenger: binaryMessenger
)
channel.setMethodCallHandler { methodCall, result in
...
}
Send initPhotoEditor message from Flutter to Android for initializing Photo Editor SDK:
await platformChannel.invokeMethod(methodInitPhotoEditor, LICENSE_TOKEN);
where initialize Photo Editor using the license token and PhotoEditorConfig
let photoEditorSDK = BanubaPhotoEditor(
token: token,
configuration: PhotoEditorConfig()
)
Send startPhotoEditor message from Flutter to iOS
dynamic result = await platformChannel.invokeMethod('startPhotoEditor');
and add corresponding handler on iOS side to start Photo Editor Photo Editor in PhotoEditorModule
.
+ let launchConfig = PhotoEditorLaunchConfig(
hostController: controller,
entryPoint: .gallery
)
photoEditorSDK?.delegate = self
photoEditorSDK?.getLicenseState(completion: { [weak self] isValid in
guard let self else { return }
if isValid {
print("✅ License is active, all good")
+ photoEditorSDK?.presentPhotoEditor(
withLaunchConfiguration: launchConfig,
completion: nil
)
} else {
print("❌ License is either revoked or expired")
}
})
Important
- Instance
photoEditorSDK
isnil
if the license token is incorrect. In this case you cannot use photo editor. Check your license token. - It is highly recommended to check if the license if active before starting Photo Editor.
This quickstart guide has just covered how to quickly integrate iOS Photo Editor SDK, it is considered you managed to start photo editor from your Flutter project.
Please check out docs to know more about the SDK and complete full integration.