Skip to content

Commit 868e2ad

Browse files
authored
fix: correct parameter order in a parseTextStyle function call (#5566)
* fix: correct parameter order in parseTextStyle function * fix: update Taskfile for improved test and installation commands * fix: mkdocs warnings * fix: enhance integration tests for ElevatedButton styles and conflicts
1 parent 4ea9558 commit 868e2ad

File tree

20 files changed

+103
-44
lines changed

20 files changed

+103
-44
lines changed

packages/flet/lib/src/controls/container.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ class ContainerControl extends StatelessWidget with FletStoreMixin {
199199
container = IgnorePointer(child: container);
200200
}
201201

202-
return ConstrainedControl(
203-
control: control,
204-
child: container,
205-
);
202+
return ConstrainedControl(control: control, child: container);
206203
}
207204
}

packages/flet/lib/src/utils/buttons.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import 'package:flutter/cupertino.dart';
33
import 'package:flutter/material.dart';
44

55
import '../models/control.dart';
6-
import '../utils/text.dart';
7-
import '../utils/theme.dart';
8-
import '../utils/time.dart';
9-
import '../utils/transforms.dart';
6+
import 'text.dart';
7+
import 'theme.dart';
8+
import 'time.dart';
9+
import 'transforms.dart';
1010
import 'alignment.dart';
1111
import 'borders.dart';
1212
import 'colors.dart';
1313
import 'edge_insets.dart';
14+
import 'geometry.dart';
1415
import 'material_state.dart';
1516
import 'mouse.dart';
1617
import 'numbers.dart';
@@ -60,6 +61,9 @@ ButtonStyle? parseButtonStyle(dynamic value, ThemeData theme,
6061
iconSize: parseWidgetStateDouble(value["icon_size"]),
6162
visualDensity: parseVisualDensity(value["visual_density"]),
6263
mouseCursor: parseWidgetStateMouseCursor(value["mouse_cursor"]),
64+
fixedSize: parseWidgetStateSize(value["fixed_size"]),
65+
maximumSize: parseWidgetStateSize(value["maximum_size"]),
66+
minimumSize: parseWidgetStateSize(value["minimum_size"]),
6367
);
6468
}
6569

packages/flet/lib/src/utils/text.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ WidgetStateProperty<TextStyle?>? parseWidgetStateTextStyle(
210210
WidgetStateProperty<TextStyle?>? defaultValue}) {
211211
if (value == null) return defaultValue;
212212
return getWidgetStateProperty<TextStyle?>(
213-
value, (jv) => parseTextStyle(theme, jv), defaultTextStyle);
213+
value, (jv) => parseTextStyle(jv, theme), defaultTextStyle);
214214
}
215215

216216
extension TextParsers on Control {

sdk/python/Taskfile.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tasks:
1515
setup:
1616
desc: "Setup environment by installing all pyproject.toml dependencies and pre-commit hooks."
1717
cmds:
18-
- task: pyproject-setup
18+
- task: install
1919
- task: pre-commit-install
2020

2121
venv-init:
@@ -25,22 +25,36 @@ tasks:
2525
cmds:
2626
- uv venv
2727

28-
tests:
29-
desc: "Run unit tests."
28+
unit-tests:
29+
desc: "Run all unit tests."
3030
aliases:
3131
- test
32+
- utest
33+
- unit-test
3234
cmds:
3335
- uv run --group test pytest packages/flet/tests
3436

35-
control-tests:
36-
desc: "Run integration tests for controls."
37+
integration-tests:
38+
desc: "Run all integration tests."
39+
aliases:
40+
- itest
41+
- integration-test
42+
cmds:
43+
- uv run pytest -s -o log_cli=true -o log_cli_level=DEBUG packages/flet/integration_tests
44+
45+
control-integration-tests:
46+
desc: "Run all controls integration tests."
47+
aliases:
48+
- control-itest
49+
- control-integration-test
3750
cmds:
3851
- uv run pytest -s -o log_cli=true -o log_cli_level=DEBUG packages/flet/integration_tests/controls
3952

40-
pyproject-setup:
53+
install:
4154
desc: "Install all pyproject.toml dependencies present in 'all' dependency-group."
4255
aliases:
4356
- pyproject
57+
- pyproject-setup
4458
cmds:
4559
- uv pip install -r pyproject.toml --group all
4660

sdk/python/packages/flet-cli/src/flet_cli/cli.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ def set_default_subparser(
2121
This should be called after setting up the argument parser but before
2222
`parse_args()`.
2323
24-
Parameters:
25-
- name (str): The name of the default subparser to use.
26-
- args (list, optional): A list of arguments passed to `parse_args()`. Defaults
27-
to None.
28-
- index (int): Position in `sys.argv` where the default subparser should be
29-
inserted. Defaults to 0.
24+
Args:
25+
name: The name of the default subparser to use.
26+
args: A list of arguments passed to `parse_args()`.
27+
index: Position in `sys.argv` where the default subparser should be
28+
inserted.
3029
"""
3130

3231
# exit if help or version flags are present

sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/elevated_button_basic.png renamed to sdk/python/packages/flet/integration_tests/controls/golden/macos/elevated_button/basic.png

File renamed without changes.
4.81 KB
Loading
4.88 KB
Loading

sdk/python/packages/flet/integration_tests/controls/test_elevated_button.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
@pytest.mark.asyncio(loop_scope="module")
8-
async def test_elevated_button_basic(flet_app: ftt.FletTestApp, request):
8+
async def test_basic(flet_app: ftt.FletTestApp, request):
99
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
1010
await flet_app.assert_control_screenshot(
1111
request.node.name,
@@ -32,3 +32,44 @@ async def test_issue_5538(flet_app: ftt.FletTestApp, request):
3232
]
3333
),
3434
)
35+
36+
37+
@pytest.mark.asyncio(loop_scope="module")
38+
async def test_button_style(flet_app: ftt.FletTestApp, request):
39+
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
40+
await flet_app.assert_control_screenshot(
41+
request.node.name,
42+
ft.ElevatedButton(
43+
content="Test Button",
44+
style=ft.ButtonStyle(
45+
bgcolor=ft.Colors.BLUE,
46+
shape=ft.RoundedRectangleBorder(radius=10),
47+
side=ft.BorderSide(width=3, color=ft.Colors.YELLOW),
48+
padding=ft.Padding.all(20),
49+
text_style=ft.TextStyle(
50+
size=15,
51+
weight=ft.FontWeight.BOLD,
52+
color=ft.Colors.WHITE,
53+
),
54+
),
55+
),
56+
)
57+
58+
59+
@pytest.mark.asyncio(loop_scope="module")
60+
async def test_button_style_conflicts(flet_app: ftt.FletTestApp, request):
61+
flet_app.page.theme_mode = ft.ThemeMode.LIGHT
62+
await flet_app.assert_control_screenshot(
63+
request.node.name,
64+
ft.ElevatedButton(
65+
content="Test Button",
66+
elevation=10,
67+
color=ft.Colors.BLACK,
68+
bgcolor=ft.Colors.BLUE,
69+
style=ft.ButtonStyle(
70+
elevation=2,
71+
color=ft.Colors.WHITE,
72+
bgcolor=ft.Colors.RED,
73+
),
74+
),
75+
)

sdk/python/packages/flet/src/flet/controls/core/text_span.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class TextSpan(Control):
4747
"""
4848
The URL to open when this button is clicked.
4949
50-
Additionally, if [`on_click`][ft.TextSpan.on_click] event callback is provided,
50+
Additionally, if [`on_click`][flet.TextSpan.on_click] event callback is provided,
5151
it is fired after that.
5252
"""
5353

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

6262
spell_out: Optional[bool] = None
6363
"""
64-
Whether the assistive technologies should spell out this text character by character.
64+
Whether the assistive technologies should spell out this text
65+
character by character.
6566
66-
If the text is 'hello world', setting this to true causes the assistive technologies,
67-
such as VoiceOver or TalkBack, to pronounce 'h-e-l-l-o-space-w-o-r-l-d' instead of complete words.
67+
If the text is 'hello world', setting this to true causes the assistive
68+
technologies, such as VoiceOver or TalkBack, to pronounce
69+
'h-e-l-l-o-space-w-o-r-l-d' instead of complete words.
6870
This is useful for texts, such as passwords or verification codes.
6971
7072
If this span contains other text span children, they also inherit the property from
7173
this span unless explicitly set.
7274
73-
If the property is not set, this text span inherits the spell out setting from its parent.
74-
If this text span does not have a parent or the parent does not have a spell out setting,
75-
this text span does not spell out the text by default.
75+
If the property is not set, this text span inherits the spell out setting
76+
from its parent. If this text span does not have a parent or the parent does
77+
not have a spell out setting, this text span does not spell out the text by default.
7678
"""
7779

7880
on_click: Optional[ControlEventHandler["TextSpan"]] = None

0 commit comments

Comments
 (0)