This project demonstrates how to integrate the img.ly CreativeEditor SDK into a Flutter web app using an iframe and JavaScript interop.
- The app uses a Flutter web project with an iframe to load the img.ly editor.
- Communication between Flutter and the editor is done via
postMessage
. - The editor is loaded from a local HTML file (
assets/editor.html
).
lib/main.dart
: Contains the Flutter app code. No changes needed unless you want to modify the UI or behavior.assets/editor.html
: Contains the img.ly editor integration. This is where you add your license key and configure the editor.
- Open
assets/editor.html
. - Locate the
defaultConfig
object in the script section:const defaultConfig = { license: '', // Add your img.ly license here ui: { elements: { navigation: { show: true, position: 'bottom' } } } };
- Replace the empty string with your license key:
license: 'your-license-key-here',
- Save the file.
- Install dependencies:
flutter pub get
- Run the app locally:
flutter run -d chrome
- Editor Not Loading: Check the browser console for errors. Ensure the img.ly SDK is loaded and the license is valid.
- CORS Issues: Run the app using
flutter run -d chrome
to avoid CORS issues.
For more details, refer to the img.ly documentation.