Skip to content

Conversation

@ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Nov 9, 2025

Fix #5193

Example

import time

import flet as ft


def main(page: ft.Page):
    page.window.title_bar_hidden = True
    page.horizontal_alignment = page.vertical_alignment = "center"

    def handle_click(e: ft.Event[ft.Button]):
        start = time.time()
        page.window.maximized = not page.window.maximized
        page.update()
        print(f"{e.control.content}: {time.time() - start:.5f}")

    page.add(
        ft.WindowDragArea(ft.Button(content="With WDA", on_click=handle_click)),
        ft.Button(content="Without WDA", on_click=handle_click),
    )


ft.run(main)

Summary by Sourcery

Improve WindowDragAreaControl responsiveness by separating dragging from double-tap detection, implement custom pointer‐based double-tap maximize/unmaximize, and add a utility distance method to Offset in the Python SDK.

New Features:

  • Add manual double-tap detection to WindowDragAreaControl to toggle window maximization

Enhancements:

  • Convert WindowDragAreaControl to a StatefulWidget and separate drag and pointer listeners for smoother dragging
  • Trigger drag_start and drag_end events consistently via the updated GestureDetector

Chores:

  • Introduce a distance property on the Python Offset class for magnitude calculation

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the WindowDragArea control to use manual double-tap detection and adds a distance property to Python's Offset class for calculating Euclidean distance.

  • Replaced GestureDetector.onDoubleTap with custom double-tap detection using Listener and pointer events
  • Converted WindowDragAreaControl from StatelessWidget to StatefulWidget to track tap timing and position
  • Added distance property to Python's Offset class to provide parity with Flutter's Offset API

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
sdk/python/packages/flet/src/flet/controls/transform.py Adds a distance property to the Offset class that calculates the Euclidean distance from the origin using the standard formula (x² + y²)^0.5
packages/flet/lib/src/controls/window_drag_area.dart Refactors WindowDragArea to use StatefulWidget with manual double-tap detection via Listener, tracking tap timing and position to determine when maximize/unmaximize should trigger based on Flutter's double-tap thresholds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 9, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5de6aa4
Status: ✅  Deploy successful!
Preview URL: https://eef79074.flet-docs.pages.dev
Branch Preview URL: https://improve-window-drag-area.flet-docs.pages.dev

View logs

ndonkoHenri and others added 4 commits November 10, 2025 00:20
Assigns the 'value' property of the Markdown control during initialization instead of within each test. Also removes the 'similarity_threshold' parameter from screenshot assertions for consistency.
@FeodorFitsner FeodorFitsner merged commit 840dde9 into main Nov 10, 2025
23 of 44 checks passed
@FeodorFitsner FeodorFitsner deleted the improve-window-drag-area branch November 10, 2025 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WindowDragArea slows down nested functionality perfomance

3 participants