Drawing in Flutter using CustomPainter

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ย. 2024
  • Follow us on :
    instagram : / moie_studio
    github : github.com/sha...
    /// Code to take a pic
    First you need to wrap CustomPaint widget with Repaintboundary and a key
    RepaintBoundary(key:repaintKey, child CustomPaint:......
    Now to take picture of what you have drawn can use this code
    RenderRepaintBoundary boundary = globalKey.currentContext.findRenderObject();
    Image image = await boundary.toImage(pixelRatio: 3.0);
    ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
    var pngBytes = byteData.buffer.asUint8List();
    var bs64 = base64Encode(pngBytes);
    Now you can use base64 to generate an image or share the image

ความคิดเห็น • 18

  • @vpraneeth554
    @vpraneeth554 4 ปีที่แล้ว +3

    Who are You, Who are so Wise in the Ways of Flutter ? Seriously thanks for the tutorial .

    • @MOIESTUDIO
      @MOIESTUDIO  4 ปีที่แล้ว +1

      Thanks a lot :) do checkout our other flutter videos also and do subscribe to our channel 😊

  • @ajaykotiyal427
    @ajaykotiyal427 11 หลายเดือนก่อน

    Good explaination! but what was the use of rxdart ? BehaviorSubject ?

  • @medaditea
    @medaditea 4 ปีที่แล้ว +2

    The Besttt 🌸

    • @MOIESTUDIO
      @MOIESTUDIO  4 ปีที่แล้ว +1

      Thank you 🤗

  • @eng6070
    @eng6070 10 หลายเดือนก่อน

    anyone know how to solve pointList.add(null)? The argument type 'Null' can't be assigned to the parameter type 'DrawModel'.?

  • @rajasjoshi4076
    @rajasjoshi4076 3 ปีที่แล้ว

    This is too good man!! 👌👌

  • @rehan-6377
    @rehan-6377 ปีที่แล้ว

    Thanks ,
    My drawing canvas still starts to hang after intensive drawing even after using stream builder instead of set state.
    Anyways Thanks for tutorial.

  • @yasminsalah3404
    @yasminsalah3404 4 ปีที่แล้ว +1

    Nice

    • @MOIESTUDIO
      @MOIESTUDIO  4 ปีที่แล้ว

      Thank you 😬 support us for more such content

  • @nicolasbarrionuevo9694
    @nicolasbarrionuevo9694 3 ปีที่แล้ว

    What is the variable ui in the ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);?

    • @MOIESTUDIO
      @MOIESTUDIO  3 ปีที่แล้ว

      I've imported dart.ui as ui

  • @ezekielho8871
    @ezekielho8871 3 ปีที่แล้ว

    How to solve unimplemented error

  • @nishilraiyarela5141
    @nishilraiyarela5141 3 ปีที่แล้ว

    Can we draw on PDF and then save PDF with the drawings we have done on it? If not do you know any way to do it?

    • @MOIESTUDIO
      @MOIESTUDIO  3 ปีที่แล้ว +1

      I'm not sure if we can draw on a pdf, I'll look into it

    • @boring-person-rishabh
      @boring-person-rishabh 2 ปีที่แล้ว

      You can try to use the stack widget
      Basically you can render the drawing widget over the pdf view, however the pdf is not being edited directly but we can save the offset information along the widget and store it locally or on a server.
      Were you able to find a solution for the problem I also wanted this feature in my app.

  • @matheusgalvao6803
    @matheusgalvao6803 3 ปีที่แล้ว

    When I try to draw it gives me this error
    ════════ Exception caught by gesture ═══════════════════════════════════════════
    The method 'findRenderObject' was called on null.
    Receiver: null
    Tried calling: findRenderObject()
    ═════════════════════════════════════════════════════════════════════
    Could you help me please?

    • @vbenavides
      @vbenavides 2 ปีที่แล้ว +1

      it is not possible assign null values a list with offsett types, it is not working with Flutter 3.0