Skip to content

fix: correct parameter order in a parseTextStyle function call #5566

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

Merged
merged 4 commits into from
Aug 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/flet/lib/src/controls/container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ class ContainerControl extends StatelessWidget with FletStoreMixin {
container = IgnorePointer(child: container);
}

return ConstrainedControl(
control: control,
child: container,
);
return ConstrainedControl(control: control, child: container);
}
}
12 changes: 8 additions & 4 deletions packages/flet/lib/src/utils/buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import '../models/control.dart';
import '../utils/text.dart';
import '../utils/theme.dart';
import '../utils/time.dart';
import '../utils/transforms.dart';
import 'text.dart';
import 'theme.dart';
import 'time.dart';
import 'transforms.dart';
import 'alignment.dart';
import 'borders.dart';
import 'colors.dart';
import 'edge_insets.dart';
import 'geometry.dart';
import 'material_state.dart';
import 'mouse.dart';
import 'numbers.dart';
Expand Down Expand Up @@ -60,6 +61,9 @@ ButtonStyle? parseButtonStyle(dynamic value, ThemeData theme,
iconSize: parseWidgetStateDouble(value["icon_size"]),
visualDensity: parseVisualDensity(value["visual_density"]),
mouseCursor: parseWidgetStateMouseCursor(value["mouse_cursor"]),
fixedSize: parseWidgetStateSize(value["fixed_size"]),
maximumSize: parseWidgetStateSize(value["maximum_size"]),
minimumSize: parseWidgetStateSize(value["minimum_size"]),
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/flet/lib/src/utils/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ WidgetStateProperty<TextStyle?>? parseWidgetStateTextStyle(
WidgetStateProperty<TextStyle?>? defaultValue}) {
if (value == null) return defaultValue;
return getWidgetStateProperty<TextStyle?>(
value, (jv) => parseTextStyle(theme, jv), defaultTextStyle);
value, (jv) => parseTextStyle(jv, theme), defaultTextStyle);
}

extension TextParsers on Control {
Expand Down
26 changes: 20 additions & 6 deletions sdk/python/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks:
setup:
desc: "Setup environment by installing all pyproject.toml dependencies and pre-commit hooks."
cmds:
- task: pyproject-setup
- task: install
- task: pre-commit-install

venv-init:
Expand All @@ -25,22 +25,36 @@ tasks:
cmds:
- uv venv

tests:
desc: "Run unit tests."
unit-tests:
desc: "Run all unit tests."
aliases:
- test
- utest
- unit-test
cmds:
- uv run --group test pytest packages/flet/tests

control-tests:
desc: "Run integration tests for controls."
integration-tests:
desc: "Run all integration tests."
aliases:
- itest
- integration-test
cmds:
- uv run pytest -s -o log_cli=true -o log_cli_level=DEBUG packages/flet/integration_tests

control-integration-tests:
desc: "Run all controls integration tests."
aliases:
- control-itest
- control-integration-test
cmds:
- uv run pytest -s -o log_cli=true -o log_cli_level=DEBUG packages/flet/integration_tests/controls

pyproject-setup:
install:
desc: "Install all pyproject.toml dependencies present in 'all' dependency-group."
aliases:
- pyproject
- pyproject-setup
cmds:
- uv pip install -r pyproject.toml --group all

Expand Down
11 changes: 5 additions & 6 deletions sdk/python/packages/flet-cli/src/flet_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ def set_default_subparser(
This should be called after setting up the argument parser but before
`parse_args()`.

Parameters:
- name (str): The name of the default subparser to use.
- args (list, optional): A list of arguments passed to `parse_args()`. Defaults
to None.
- index (int): Position in `sys.argv` where the default subparser should be
inserted. Defaults to 0.
Args:
name: The name of the default subparser to use.
args: A list of arguments passed to `parse_args()`.
index: Position in `sys.argv` where the default subparser should be
inserted.
"""

# exit if help or version flags are present
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@pytest.mark.asyncio(loop_scope="module")
async def test_elevated_button_basic(flet_app: ftt.FletTestApp, request):
async def test_basic(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
request.node.name,
Expand All @@ -32,3 +32,44 @@ async def test_issue_5538(flet_app: ftt.FletTestApp, request):
]
),
)


@pytest.mark.asyncio(loop_scope="module")
async def test_button_style(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
request.node.name,
ft.ElevatedButton(
content="Test Button",
style=ft.ButtonStyle(
bgcolor=ft.Colors.BLUE,
shape=ft.RoundedRectangleBorder(radius=10),
side=ft.BorderSide(width=3, color=ft.Colors.YELLOW),
padding=ft.Padding.all(20),
text_style=ft.TextStyle(
size=15,
weight=ft.FontWeight.BOLD,
color=ft.Colors.WHITE,
),
),
),
)


@pytest.mark.asyncio(loop_scope="module")
async def test_button_style_conflicts(flet_app: ftt.FletTestApp, request):
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
await flet_app.assert_control_screenshot(
request.node.name,
ft.ElevatedButton(
content="Test Button",
elevation=10,
color=ft.Colors.BLACK,
bgcolor=ft.Colors.BLUE,
style=ft.ButtonStyle(
elevation=2,
color=ft.Colors.WHITE,
bgcolor=ft.Colors.RED,
),
),
)
16 changes: 9 additions & 7 deletions sdk/python/packages/flet/src/flet/controls/core/text_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TextSpan(Control):
"""
The URL to open when this button is clicked.

Additionally, if [`on_click`][ft.TextSpan.on_click] event callback is provided,
Additionally, if [`on_click`][flet.TextSpan.on_click] event callback is provided,
it is fired after that.
"""

Expand All @@ -61,18 +61,20 @@ class TextSpan(Control):

spell_out: Optional[bool] = None
"""
Whether the assistive technologies should spell out this text character by character.
Whether the assistive technologies should spell out this text
character by character.

If the text is 'hello world', setting this to true causes the assistive technologies,
such as VoiceOver or TalkBack, to pronounce 'h-e-l-l-o-space-w-o-r-l-d' instead of complete words.
If the text is 'hello world', setting this to true causes the assistive
technologies, such as VoiceOver or TalkBack, to pronounce
'h-e-l-l-o-space-w-o-r-l-d' instead of complete words.
This is useful for texts, such as passwords or verification codes.

If this span contains other text span children, they also inherit the property from
this span unless explicitly set.

If the property is not set, this text span inherits the spell out setting from its parent.
If this text span does not have a parent or the parent does not have a spell out setting,
this text span does not spell out the text by default.
If the property is not set, this text span inherits the spell out setting
from its parent. If this text span does not have a parent or the parent does
not have a spell out setting, this text span does not spell out the text by default.
"""

on_click: Optional[ControlEventHandler["TextSpan"]] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class CupertinoButton(ConstrainedControl):
"""
The URL to open when this button is clicked.

Additionally, if [`on_click`][ft.CupertinoButton.on_click] event callback is
Additionally, if [`on_click`][flet.CupertinoButton.on_click] event callback is
provided, it is fired after that.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class CupertinoListTile(ConstrainedControl):
"""
The URL to open when this button is clicked.

Additionally, if [`on_click`][ft.CupertinoListTile.on_click] event callback is
Additionally, if [`on_click`][flet.CupertinoListTile.on_click] event callback is
provided, it is fired after that.
"""

Expand Down
12 changes: 7 additions & 5 deletions sdk/python/packages/flet/src/flet/controls/material/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class Container(ConstrainedControl, AdaptiveControl):
"""
Defines how the [`content`][flet.Container.content] of the container is clipped.

Defaults to `ClipBehavior.ANTI_ALIAS` if [`border_radius`][flet.Container.border_radius] is not `None`;
Defaults to `ClipBehavior.ANTI_ALIAS` if
[`border_radius`][flet.Container.border_radius] is not `None`;
otherwise `ClipBehavior.NONE`.
"""

Expand Down Expand Up @@ -180,7 +181,7 @@ class Container(ConstrainedControl, AdaptiveControl):
"""
The URL to open when this container is clicked.

Additionally, if [`on_click`][ft.Container.on_click] event callback is provided,
Additionally, if [`on_click`][flet.Container.on_click] event callback is provided,
it is fired after that.
"""

Expand Down Expand Up @@ -241,7 +242,8 @@ def main(page: ft.Page):
theme_mode: Optional[ThemeMode] = None
"""
"Resets" parent theme and creates a new, unique scheme for all
controls inside the container. Otherwise the styles defined in container's [`theme`][flet.Container.theme]
controls inside the container. Otherwise the styles defined in
container's [`theme`][flet.Container.theme]
property override corresponding styles from the parent, inherited theme.

Defaults to `ThemeMode.SYSTEM`.
Expand Down Expand Up @@ -321,8 +323,8 @@ def on_tap_down(e: ft.ContainerTapEvent):
"""
Called when a mouse pointer enters or exists the container area.

The `data` property of the event handler argument is `True` when the cursor enters and
`False` when it exits.
The `data` property of the event handler argument is `True`
when the cursor enters and `False` when it exits.

Example:
A container changing its background color on mouse hover:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class ElevatedButton(ConstrainedControl, AdaptiveControl):
"""
The URL to open when this button is clicked.

Additionally, if [`on_click`][ft.ElevatedButton.on_click] event callback is
Additionally, if [`on_click`][flet.ElevatedButton.on_click] event callback is
provided, it is fired after that.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class FloatingActionButton(ConstrainedControl):
"""
The URL to open when this button is clicked.

Additionally, if [`on_click`][ft.FloatingActionButton.on_click] event callback
Additionally, if [`on_click`][flet.FloatingActionButton.on_click] event callback
is provided, it is fired after that.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def toggle_icon_button(e):
"""
The URL to open when this button is clicked.

Additionally, if [`on_click`][ft.IconButton.on_click] event callback is provided,
Additionally, if [`on_click`][flet.IconButton.on_click] event callback is provided,
it is fired after that.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ListTile(ConstrainedControl, AdaptiveControl):
"""
The URL to open when this button is clicked.

Additionally, if [`on_click`][ft.ListTile.on_click] event callback is provided,
Additionally, if [`on_click`][flet.ListTile.on_click] event callback is provided,
it is fired after that.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class OutlinedButton(ConstrainedControl, AdaptiveControl):
"""
The URL to open when this button is clicked.

Additionally, if [`on_click`][ft.OutlinedButton.on_click] event callback is
Additionally, if [`on_click`][flet.OutlinedButton.on_click] event callback is
provided, it is fired after that.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TextButton(ConstrainedControl, AdaptiveControl):
"""
The URL to open when this button is clicked.

Additionally, if [`on_click`][ft.TextButton.on_click] event callback is
Additionally, if [`on_click`][flet.TextButton.on_click] event callback is
provided, it is fired after that.
"""

Expand All @@ -79,7 +79,7 @@ class TextButton(ConstrainedControl, AdaptiveControl):
"""
Called when a mouse pointer enters or exists this button's response area.

The [`data`][ft.Event.data] property of event object is `True` when cursor
The [`data`][flet.Event.data] property of event object is `True` when cursor
enters and `False` when it exits.
"""

Expand Down
2 changes: 1 addition & 1 deletion sdk/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ show-fixes = true

[tool.ruff.lint]
pydocstyle = { convention = 'google' }
isort = { known-first-party = ["flet"] }
isort = { known-first-party = ["flet", "flet_cli"] }
preview = true
select = [
# pycodestyle
Expand Down
Loading