Search code examples
flutterquill

flutter_quill: How to programmatically set size attributes of a picked up image?


https://pub.dev/packages/flutter_quill page refers to "Custom Size Image for Mobile", however, I am unable to find an example to do the same through code.


  var imageURL =
      'https://user-images.githubusercontent.com/122956/72955931-ccc07900-3d52-11ea-89b1-d468a6e2aa2b.png';

  final doc = Document()..insert(0, BlockEmbed.image(imageURL));

  setState(() {
    _controller = QuillController(
        document: doc, selection: const TextSelection.collapsed(offset: 0));
  });

I am looking for a solution to specify attributes for a particular delta.


Solution

  • I use controller to add Style like this

    _controller.document.insert(_controller.selection.start , BlockEmbed("image", stl));
    _controller.document.format(_controller.selection.start,1,StyleAttribute("mobileWidth: ${_imageSize!.width}; mobileHeight: ${_imageSize!.height}; mobileMargin: 10; mobileAlignment: center"));