feat: LayoutControl.on_size_change event for size-awareness#6099
Merged
FeodorFitsner merged 9 commits intomainfrom Feb 4, 2026
Merged
feat: LayoutControl.on_size_change event for size-awareness#6099FeodorFitsner merged 9 commits intomainfrom
LayoutControl.on_size_change event for size-awareness#6099FeodorFitsner merged 9 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a size-change event for layout-based controls, wires it through the Flutter side, and updates container examples, docs, and tests to demonstrate size-aware behavior.
Changes:
- Add
LayoutSizeChangeEvent,on_size_change, andsize_change_intervaltoLayoutControland implement a throttledSizeChangeObserveron the Flutter side, enabling controls to be notified when their rendered size changes. - Update various Flutter plugin controls (maps, charts, ads, video, webview, rive, lottie, datatable2) to wrap content with
LayoutControlinstead ofConstrainedControl, and exposeLayoutSizeChangeEventat the PythonfletAPI. - Refresh container docs and examples (including a new size-aware example and an animated overlay menu), and add integration screenshot tests and goldens for container size-awareness and nested themes.
Reviewed changes
Copilot reviewed 26 out of 32 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/python/packages/flet/src/flet/controls/material/reorderable_list_view.py | Minor doc tweak adding an “Example:” label for the existing ListView example. |
| sdk/python/packages/flet/src/flet/controls/layout_control.py | Introduces LayoutSizeChangeEvent, adds size_change_interval and on_size_change to LayoutControl, and cleans up examples and the deprecated ConstrainedControl alias. |
| sdk/python/packages/flet/src/flet/controls/core/gesture_detector.py | Clarifies the drag_interval documentation wording without changing behavior. |
| sdk/python/packages/flet/src/flet/init.py | Re-exports LayoutSizeChangeEvent and adds it to the public symbol list so it’s available as ft.LayoutSizeChangeEvent. |
| sdk/python/packages/flet/integration_tests/examples/material/test_container.py | Adds screenshot-based integration tests for the size_aware, nested_themes_1, and nested_themes_2 container examples. |
| sdk/python/packages/flet/integration_tests/examples/material/golden/macos/container/size_aware.png | New macOS golden image for the size-aware container example. |
| sdk/python/packages/flet/integration_tests/examples/material/golden/macos/container/nested_themes_2.png | New/updated macOS golden image for the nested_themes_2 container example. |
| sdk/python/packages/flet/integration_tests/examples/material/golden/macos/container/nested_themes_1.png | New macOS golden image for the nested_themes_1 container example. |
| sdk/python/packages/flet/docs/controls/container.md | Simplifies image includes (dropping explicit alt attributes), removes the old background_color example block, and documents the new size-aware and nested theme examples. |
| sdk/python/packages/flet-webview/src/flutter/flet_webview/lib/src/webview.dart | Wraps the platform-specific webview with LayoutControl instead of the now-removed ConstrainedControl widget. |
| sdk/python/packages/flet-video/src/flutter/flet_video/lib/src/video.dart | Uses LayoutControl to wrap the video player widget and slightly tidies playlist construction. |
| sdk/python/packages/flet-rive/src/flutter/flet_rive/lib/src/rive.dart | Wraps both placeholder and loaded rive widgets in LayoutControl, replacing ConstrainedControl. |
| sdk/python/packages/flet-map/src/flutter/flet_map/lib/src/tile_layer.dart | Wraps the tile layer widget in LayoutControl to be consistent with the new layout pipeline. |
| sdk/python/packages/flet-map/src/flutter/flet_map/lib/src/map.dart | Wraps the map widget with LayoutControl instead of ConstrainedControl. |
| sdk/python/packages/flet-lottie/src/flutter/flet_lottie/lib/src/lottie.dart | Uses LayoutControl to host the Lottie animation widget. |
| sdk/python/packages/flet-datatable2/src/flutter/flet_datatable2/lib/src/datatable2.dart | Wraps the DataTable2 widget with LayoutControl. |
| sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/scatter_chart.dart | Replaces ConstrainedControl with LayoutControl for scatter chart rendering. |
| sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/radar_chart.dart | Replaces ConstrainedControl with LayoutControl for radar chart rendering. |
| sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/pie_chart.dart | Replaces ConstrainedControl with LayoutControl for pie chart rendering. |
| sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/line_chart.dart | Replaces ConstrainedControl with LayoutControl for line chart rendering. |
| sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/candlestick_chart.dart | Replaces ConstrainedControl with LayoutControl for candlestick chart rendering. |
| sdk/python/packages/flet-charts/src/flutter/flet_charts/lib/src/bar_chart.dart | Replaces ConstrainedControl with LayoutControl for bar chart rendering. |
| sdk/python/packages/flet-ads/src/flutter/flet_ads/lib/src/native.dart | Wraps the native ad widget in LayoutControl so it participates in the unified layout/event pipeline. |
| sdk/python/packages/flet-ads/src/flutter/flet_ads/lib/src/banner.dart | Wraps the banner ad widget in LayoutControl. |
| sdk/python/examples/controls/container/size_aware.py | Replaces the custom SizeAwareContainer canvas control with a simpler example using Container.on_size_change and LayoutSizeChangeEvent. |
| sdk/python/examples/controls/container/nested_themes_2.py | Makes the example script runnable as __main__ without side effects on import. |
| sdk/python/examples/controls/container/nested_themes_1.py | Same if __name__ == "__main__": guard pattern added for the first nested themes example. |
| sdk/python/examples/controls/container/background_color.py | Removes the outdated background-color container example, consistent with the docs cleanup. |
| sdk/python/examples/controls/container/animate_4.py | Adds a new example showing an animated slide-in overlay menu using Container.offset and animate_offset. |
| sdk/python/examples/controls/container/init.py | Package file (unchanged content) enabling examples.controls.container imports used by the new tests. |
| packages/flet/lib/src/controls/base_controls.dart | Removes the ConstrainedControl widget, adds a _sizeChangeObserver hook into LayoutControl, and implements SizeChangeObserver/MeasureSize to trigger a throttled "size_change" event with measured w/h. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying flet-docs with
|
| Latest commit: |
047f534
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c879401e.flet-docs.pages.dev |
| Branch Preview URL: | https://size-aware.flet-docs.pages.dev |
Deploying flet-examples with
|
| Latest commit: |
047f534
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c9d1c2a9.flet-examples.pages.dev |
| Branch Preview URL: | https://size-aware.flet-examples.pages.dev |
FeodorFitsner
approved these changes
Jan 31, 2026
…tionBar` + update `Tabs` example file paths to use underscores instead of hyphens
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #6081
Test code
Summary by Sourcery
Add an opt-in layout size change event to layout-based controls and migrate dependent widgets to use the unified LayoutControl wrapper.
New Features:
Enhancements:
Documentation:
Tests: