openEditor method

  1. @override
Future<EditorResult?> openEditor({
  1. Source? source,
  2. EditorPreset? preset = EditorPreset.design,
  3. required EditorSettings settings,
  4. Map<String, dynamic>? metadata,
})
override

Opens the creative editor.

The editor will be opened with the given source or the default asset if null. If desired, the editor can be opened from a given UI preset which is EditorPreset.design by default. The settings include all the properties needed for the editor to work, e.g. the license and the CDN for assets. Optionally, metadata can also be specified which is not used by the plugin other than with a custom implementation.

Implementation

@override
Future<EditorResult?> openEditor(
    {Source? source,
    EditorPreset? preset = EditorPreset.design,
    required EditorSettings settings,
    Map<String, dynamic>? metadata}) async {
  if (preset == EditorPreset.video && !Platform.isIOS) {
    throw ("`EditorPreset.video` is not supported on Android.");
  }
  final result = await methodChannel.invokeMethod("openEditor", {
    "preset": preset?.stringValue,
    "settings": {"source": source?.toJson(), ...settings.toJson()},
    "metadata": metadata
  });
  return result == null
      ? null
      : EditorResult.fromJson(Map<String, dynamic>.from(result));
}