Skip to content

fix: animate_size ignored on Container and Image; False animation values failing to render - #7091

Open
ndonkoHenri wants to merge 5 commits into
mainfrom
fix/animate-size-container-5766
Open

ndonkoHenri wants to merge 5 commits into
mainfrom
fix/animate-size-container-5766

Conversation

@ndonkoHenri

@ndonkoHenri ndonkoHenri commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5766.

Two animation bugs in the shared layout code.

animate_size on Container and Image

animate_size had no effect on Container or Image. The reporter's case, a container hidden with height=0 and revealed with height=None, jumped instead of animating.

Why: _sizedControl() applies a control's width/height, wraps it in AnimatedSize for animate_size, and applies its min/max constraints. Container and Image size themselves, so they list width/height in skip_properties, and that skipped the AnimatedSize along with the size box.

Fix: controls that size themselves are wrapped in AnimatedSize when animate_size is set. AnimatedSize follows the size the control lays out at, so changes between fixed sizes and to/from the natural size (None) animate. The min/max constraints are still applied around it.

False animation values

Python documents False as "disable animation" for every animate_* property, but the client failed on it ("Class 'bool' has no instance method '[]'"), so a control with animate=False, animate_opacity=False and so on didn't render.

Fix: parseAnimation() treats False as off: no animation, or a zero-duration (instant) one where the control animates by default, such as CupertinoAlertDialog.inset_animation and the auto-scroll animation.

Testing

Integration tests in integration_tests/controls/core/test_layout_control.py, real macOS desktop client:

test what it does main this branch
test_animate_size a Container with animate_size=400 reports its height through on_size_change while going from 40 to None (its content's 200) and back; checks in-between heights arrive fails: [200.0], a straight jump pass
test_animate_false a Container with animate, animate_opacity, animate_size, animate_scale, animate_rotation, animate_offset and animate_margin all False fails: doesn't render pass

Full packages/flet Flutter suite: 183 pass; flutter analyze clean.

Summary by Sourcery

Fix shared layout animation handling so self-sizing controls animate size changes correctly and False animation settings disable animations without preventing rendering.

New Features:

  • Support smooth size transitions for self-sizing Container and Image controls, including transitions to and from natural size.
  • Emit size-specific animation completion events and report the final measured size when layout occurs multiple times in one frame.

Bug Fixes:

  • Treat False animation values as disabled so controls render correctly when individual or general animations are turned off.

Enhancements:

  • Update layout and animation documentation to describe natural-size animation, collapse behavior, and final-frame size reporting.

Documentation:

  • Document the behavior and usage of animated container collapsing and final-size on_size_change reporting.

Tests:

  • Add Flutter and desktop integration coverage for animated sizes, natural-size transitions, image resizing, animation completion events, and disabled animations.

ndonkoHenri added a commit that referenced this pull request Nov 15, 2026
Adds the pull request link to the two 1.1.3 bug-fix entries: animate_size
on Container and Image, and False animation values.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: a062724
Status: ✅  Deploy successful!
Preview URL: https://58db222d.flet-website-v2.pages.dev
Branch Preview URL: https://fix-animate-size-container-5.flet-website-v2.pages.dev

View logs

ndonkoHenri and others added 5 commits November 19, 2026 13:20
Python's `AnimationValue` documents `False` as "disable animation", but
`parseAnimation()` only handled `True`, an int and an Animation map: a
`False` fell through to `value["duration"]` and failed with "Class 'bool'
has no instance method '[]'". So `animate=False`, `animate_opacity=False`,
`animate_scale=False` and the other `animate_*` properties made the
control fail to render (SF-523).

`parseAnimation()` now treats `False` as off: it returns `null` (no
animation), or a zero-duration animation when the caller passes a default,
i.e. animates by default (CupertinoAlertDialog's `inset_animation`, the
auto-scroll animation), so those stay instant instead of failing on a
missing animation. A doc comment lists the accepted values.

Changelog: a 1.1.3 bug-fix entry.
`_sizedControl()` applies a control's width/height, its `animate_size`
AnimatedSize and its min/max constraints. Controls that size themselves
(Container and Image list `width`/`height` in `skip_properties`) skipped
the AnimatedSize together with the size box, so `animate_size` had no
effect on them (#5766). The reporter's case: a Container whose height goes
from a fixed value to `None` (its content's size) and back jumped instead
of animating.

Such controls are now wrapped in AnimatedSize when `animate_size` is set.
AnimatedSize follows the size the control lays out at, so it animates
changes between fixed sizes and to/from the natural size. The min/max
constraints are still applied around it. Controls that don't size
themselves keep the AnimatedSize in `_fixedSizeControl()`; both paths
read `animate_size` with `getAnimation()`, so `animate_size=False` means
no animation. The doc comment of `_sizedControl()` describes this.

Changelog: a 1.1.3 bug-fix entry.
Two integration tests in `integration_tests/controls/core/
test_layout_control.py` (real desktop client), with a `_wait_for()` helper
that pumps frames until events reach Python:
- test_animate_size: a Container with `animate_size=400`, a 200 px tall
  content and an `on_size_change` handler (`size_change_interval=0`) goes
  from height 40 to `None` and back to 40; each change must report
  heights between 40 and 200, not a single jump.
- test_animate_false: a Container with `animate`, `animate_opacity`,
  `animate_size`, `animate_scale`, `animate_rotation`, `animate_offset` and
  `animate_margin` all `False` renders and shows its text.

On macOS both pass with this branch and fail with main's
`base_controls.dart` and `animations.dart`: "no animation: [200.0]" (a
straight jump) and the text not found (the Container failed to render).
Adds the pull request link to the two 1.1.3 bug-fix entries: animate_size
on Container and Image, and False animation values.
@FeodorFitsner
FeodorFitsner force-pushed the fix/animate-size-container-5766 branch from 35b9584 to a062724 Compare November 19, 2026 20:35

This branch has not been deployed

No deployments
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.

bug: [v1] Size animation not working

2 participants