Skip to content

feat: add Page.theme_animation_style for customizing theme transitions#6476

Merged
FeodorFitsner merged 2 commits into
release/v0.85.0from
theme-animation-style
May 7, 2026
Merged

feat: add Page.theme_animation_style for customizing theme transitions#6476
FeodorFitsner merged 2 commits into
release/v0.85.0from
theme-animation-style

Conversation

@FeodorFitsner

@FeodorFitsner FeodorFitsner commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds Page.theme_animation_style: Optional[AnimationStyle], exposing Flutter's MaterialApp.themeAnimationStyle so apps can tune the duration/curve of the cross-fade between theme and dark_theme — or disable it entirely via AnimationStyle.no_animation().
  • Wires the property through both MaterialApp(...) and MaterialApp.router(...) constructions in packages/flet/lib/src/controls/page.dart (CupertinoApp branches are unchanged — Flutter has no equivalent there).
  • Adds a showcase example under sdk/python/examples/controls/core/types/theme_animation_style/showcase/ that lets the user pick between Default, Custom (2 s easeInOutCubic), and None styles, with a "Switch Theme Mode" button that toggles light/dark so the chosen transition is observable.

Test plan

  • Run the new example: cd sdk/python/examples/controls/core/types/theme_animation_style/showcase && flet run main.py
  • Select Default → click "Switch Theme Mode" → expect the standard short cross-fade
  • Select Custom → toggle theme → expect a clearly slower (~2 s) cubic-eased fade
  • Select None → toggle theme → expect an instantaneous swap with no fade
  • Verify rapid toggling during an in-flight Custom transition behaves sensibly (no crash)
  • Confirm an unrelated theme example (e.g. core/types/theme_mode/showcase) still runs unchanged with theme_animation_style defaulting to None

Summary by Sourcery

Expose configurable theme animation style on Page and showcase its usage.

New Features:

  • Add Page.theme_animation_style property to control theme transition animations between light and dark modes.
  • Support forwarding theme_animation_style to underlying Flutter MaterialApp and MaterialApp.router constructors.
  • Introduce a new Python example showcasing default, custom, and disabled theme animation styles for theme switching.

Documentation:

  • Document Page.theme_animation_style usage and its ability to disable theme transition animations in the Python API docstring.

Tests:

  • Add a gallery/showcase example project configuration for theme animation style to aid manual testing and demonstration.

Exposes Flutter's `MaterialApp.themeAnimationStyle` as a new
`Optional[AnimationStyle]` property on `Page`, letting apps override the
duration and curve of the cross-fade between `theme` and `dark_theme`,
or disable it entirely via `AnimationStyle.no_animation()`.

Adds a showcase example under
`examples/controls/core/types/theme_animation_style/` that toggles
between Default, Custom, and None styles alongside a Switch Theme Mode
button.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying flet-website-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0c49075
Status:⚡️  Build in progress...

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3e7ff60
Status: ✅  Deploy successful!
Preview URL: https://99664ba7.flet-examples.pages.dev
Branch Preview URL: https://theme-animation-style.flet-examples.pages.dev

View logs

@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.

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

@FeodorFitsner FeodorFitsner merged commit 843f0c0 into release/v0.85.0 May 7, 2026
8 of 41 checks passed
@FeodorFitsner FeodorFitsner deleted the theme-animation-style branch May 7, 2026 17:39
@ndonkoHenri ndonkoHenri added this to the 0.85.0 milestone May 7, 2026
@ndonkoHenri ndonkoHenri moved this from ✅ Done to 🔖 Ready in Flet Development May 7, 2026
@ndonkoHenri ndonkoHenri moved this from 🔖 Ready to ✅ Done in Flet Development May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants