Skip to content

Canvas + gesture detector does not work in Row parent control #4503

Answered by ndonkoHenri
BCheong1990 asked this question in Q&A
Discussion options

You must be logged in to vote

The code works on my end, I am able to draw on the canvas.

If it still doesnt work on your end, try constraining your controls, by:

  • providing width/height props
  • or adding expand=True for it to fill the available space.
import flet as ft
import flet.canvas as cv


class State:
    x: float
    y: float


state = State()


def main(page: ft.Page):
    page.title = "Flet Brush"

    def pan_start(e: ft.DragStartEvent):
        state.x = e.local_x
        state.y = e.local_y

    def pan_update(e: ft.DragUpdateEvent):
        cp.shapes.append(
            cv.Line(
                state.x, state.y, e.local_x, e.local_y, paint=ft.Paint(stroke_width=3)
            )
        )
        cp.update(…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BCheong1990
Comment options

Answer selected by ndonkoHenri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants