-
Notifications
You must be signed in to change notification settings - Fork 600
fix: Ensure consistent TextStyle inheritance during button state transitions
#5901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ignment handling
There was a problem hiding this 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
There was a problem hiding this 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 fixes TextStyle inheritance issues during button state transitions by setting inherit: false on button text styles, which prevents TextStyle.lerp assertion errors when animating between states. The change also includes various code quality improvements and documentation enhancements.
- Core fix: Modified button text style handling to explicitly set
inherit: falseto match Material button defaults - Refactored text parsing utilities to extract reusable helper functions
- Improved Python code quality with better exception handling and import organization
- Enhanced documentation for Row, ResponsiveRow, and Lottie controls
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/python/pyproject.toml | Added flet_desktop and flet_web to isort's known-first-party packages |
| sdk/python/packages/flet/src/flet/utils/pip.py | Replaced bare except with except Exception, removed redundant imports, improved error message formatting |
| sdk/python/packages/flet/src/flet/controls/core/row.py | Enhanced documentation with proper example formatting and detailed property notes |
| sdk/python/packages/flet/src/flet/controls/core/responsive_row.py | Improved documentation and fixed trailing whitespace |
| sdk/python/packages/flet-lottie/src/flet_lottie/lottie.py | Added note about layer effects limitations with relevant issue links |
| packages/flet/lib/src/utils/text.dart | Extracted parseFontVariations and parseTextDecorations as reusable helper functions |
| packages/flet/lib/src/utils/buttons.dart | Introduced parseButtonTextStyle wrapper that sets inherit: false to prevent TextStyle.lerp assertions |
| packages/flet/lib/src/controls/row.dart | Refactored to use extension methods for better code organization |
| packages/flet/lib/src/controls/button.dart | Code formatting improvements and simplified variable usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying flet-docs with
|
| Latest commit: |
7190ce5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9f1c06f4.flet-docs.pages.dev |
| Branch Preview URL: | https://fix-button-text-style.flet-docs.pages.dev |
| obj = obj.replace(tzinfo=datetime.timezone.utc) | ||
|
|
||
| # Normalize to UTC | ||
| obj = obj.astimezone(datetime.timezone.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken Flutter DateTimePicker (or other widgets) expect (and outputs) local dates, not UTC.
Converting to UTC date on Python side could give wrong results on UI.
For example, if I specify datetime(2025, 3, 10) in Python and you convert it to UTC then on a device in -07:00 timezone it will show March 9 in the picker, instead of expected March 10.
When a developer writes a naive date like 2025-10-03 in Python, most people mentally model it as a local calendar date, not UTC. Usually, UTC must be explicit.
On the other hand, using of UTC for passing datetime/time over a wire (like in Flet between Python and Flutter) is a good thing. However, on Flutter (or JavaScript in web) side you have to convert the date back to local, either on protocol level or in DateTimePicker using .toLocal(). Selected date in DatePicker should be converted back to UTC with .toUtc().
So, algorithm could be:
- "naive" datetime we convert to a local datetime then into UTC.
- local datetime is converted to UTC.
- UTC datetime goes into the wire "as is".
Does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...why passing UTC over the wire is the right solution? When you have both Python and Flutter on the same machine (mobile, desktop apps) it's fine to use local, but if you run Flet app on the web then client browsers are in time zones different from server: client receives UTC date and converts it to its local date.
Fix #5620
Fix #5278
Fix #5895
Summary by Sourcery
Improve button text style handling and polish layout, utilities, and documentation across Flutter and Python SDK components.
Bug Fixes:
Enhancements:
Build: