insertImage method

int insertImage({
  1. required String src,
  2. String? alt,
  3. double? width,
  4. double? height,
  5. String? caption,
  6. SmartTextAlign alignment = SmartTextAlign.center,
  7. int? blockIndex,
})

Inserts an image block at or after blockIndex.

If blockIndex is null, inserts at the currently focused block or appends to the document.

Implementation

int insertImage({
  required String src,
  String? alt,
  double? width,
  double? height,
  String? caption,
  SmartTextAlign alignment = SmartTextAlign.center,
  int? blockIndex,
}) {
  final targetIndex = blockIndex ?? _editorWidgetState?.focusedBlockIndex;
  final index = _documentController.insertImage(
    src: src,
    alt: alt,
    width: width,
    height: height,
    caption: caption,
    alignment: alignment,
    blockIndex: targetIndex,
  );
  _editorWidgetState?.rebuild();
  return index;
}