79534360

Date: 2025-03-25 17:00:29
Score: 0.5
Natty:
Report link

It`s easy, when u adding any elements by

page.overlay.append(element)

You can align it by Stack attributes, like this:

import flet as ft

def main(page: ft.Page):

    page.horizontal_alignment = ft.CrossAxisAlignment.CENTER
    page.vertical_alignment = ft.MainAxisAlignment.CENTER
    page.window.full_screen = True

    overlay_pic = ft.Container(
        width=1920,
        height=420,
        bgcolor="red",
        bottom=0,
    )

    def switch_overlay(e):
        if overlay_pic not in page.overlay:
            page.overlay.append(overlay_pic)
        else:
            page.overlay.remove(overlay_pic)
        page.update()


    button = ft.ElevatedButton(
        text='switch overlay',
        on_click=switch_overlay
    )


    page.add(
        button
    )

ft.app(main)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: neversleep