Skip to main content

New release: Drag and Drop, absolute positioning and clickable container

· 2 min read
Feodor Fitsner

We have just released Flet 0.1.41 with drag-and-drop support and other neat features such as absolute positioning of controls inside stack and clickable container!

Drag and Drop

Making drag-and-drop in Flet is a real joy - thanks to a smart drag-and-drop implementation in Flutter! You just have "draggable" control which could be dragged to a "drag target" which calls on_accept event handler when draggable is dropped.

Take a look at Drag-and-Drop example.

Explore Draggable and DragTarget controls, their properties and events.

Absolute positioning inside Stack

All visible controls now have left top, right and bottom properties to let them be absolutely positioned inside Stack, for example:

import flet
from flet import Container, Page, Stack, Text, colors

def main(page: Page):

page.horizontal_alignment = "center"
page.vertical_alignment = "center"

page.add(
Container(
Stack(
[
Text("1", color=colors.WHITE),
Text("2", color=colors.WHITE, right=0),
Text("3", color=colors.WHITE, right=0, bottom=0),
Text("4", color=colors.WHITE, left=0, bottom=0),
Text("5", color=colors.WHITE, left=40, top=35),
]
),
border_radius=8,
padding=5,
width=100,
height=100,
bgcolor=colors.BROWN_700,
)
)

flet.app(target=main)

Clickable container

Container control has got on_click event which allows you to make a button from any control and with a beautiful material ripple effect when ink is set to True!

See source code for the example above.

Give Flet a try and let us know what you think!