Skip to content

Commit 1759a17

Browse files
committed
Add size constraints to SearchBar and improve docs
Introduces `bar_size_constraints` to the SearchBar control and theme, allowing optional size constraints. Also updates and expands documentation for SearchBar properties and SearchBarTheme overrides for better clarity and developer guidance.
1 parent 833c67c commit 1759a17

3 files changed

Lines changed: 74 additions & 7 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ class _SearchBarControlState extends State<SearchBarControl> {
208208
shape:
209209
widget.control.getWidgetStateOutlinedBorder("bar_shape", theme),
210210
padding: widget.control.getWidgetStatePadding("bar_padding"),
211+
constraints:
212+
widget.control.getBoxConstraints("bar_size_constraints"),
211213
textStyle:
212214
widget.control.getWidgetStateTextStyle("bar_text_style", theme),
213215
hintStyle: widget.control

sdk/python/packages/flet/src/flet/controls/material/search_bar.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,37 +78,44 @@ class SearchBar(ConstrainedControl):
7878

7979
bar_shadow_color: Optional[ControlStateValue[ColorValue]] = None
8080
"""
81-
TBD
81+
The shadow color of the search bar.
8282
"""
8383

8484
bar_elevation: Optional[ControlStateValue[Optional[Number]]] = None
8585
"""
86-
TBD
86+
The elevation of the search bar.
8787
"""
8888

8989
bar_border_side: Optional[ControlStateValue[BorderSide]] = None
9090
"""
91-
TBD
91+
The color and weight of the search bar's outline.
92+
93+
This value is combined with [`SearchBar.bar_shape`][flet.SearchBar.bar_shape] to
94+
create a shape decorated with an outline.
9295
"""
9396

9497
bar_shape: Optional[ControlStateValue[OutlinedBorder]] = None
9598
"""
96-
TBD
99+
The shape of the search bar.
100+
101+
This shape is combined with
102+
[`SearchBar.bar_border_side`][flet.SearchBar.bar_border_side] to create a shape
103+
decorated with an outline.
97104
"""
98105

99106
bar_text_style: Optional[ControlStateValue[TextStyle]] = None
100107
"""
101-
TBD
108+
The style to use for the text being edited.
102109
"""
103110

104111
bar_hint_text_style: Optional[ControlStateValue[TextStyle]] = None
105112
"""
106-
TBD
113+
The style to use for the [`SearchBar.bar_hint_text`][flet.SearchBar.bar_hint_text].
107114
"""
108115

109116
bar_padding: Optional[ControlStateValue[PaddingValue]] = None
110117
"""
111-
TBD
118+
The padding between the search bar's boundary and its contents.
112119
"""
113120

114121
bar_scroll_padding: PaddingValue = 20
@@ -120,6 +127,11 @@ class SearchBar(ConstrainedControl):
120127
distance from the Scrollable edges.
121128
"""
122129

130+
bar_size_constraints: Optional[BoxConstraints] = None
131+
"""
132+
Optional size constraints for the search bar.
133+
"""
134+
123135
view_leading: Optional[Control] = None
124136
"""
125137
A `Control` to display before the text input field when the search view is open.

sdk/python/packages/flet/src/flet/controls/theme.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,14 +2875,67 @@ class SearchBarTheme:
28752875
"""
28762876

28772877
shadow_color: Optional[ControlStateValue[ColorValue]] = None
2878+
"""
2879+
Overrides the default value of
2880+
[`SearchBar.bar_shadow_color`][flet.SearchBar.bar_shadow_color] in all descendant
2881+
[`SearchBar`][flet.SearchBar] controls.
2882+
"""
2883+
28782884
overlay_color: Optional[ControlStateValue[ColorValue]] = None
2885+
"""
2886+
Overrides the default value of
2887+
[`SearchBar.bar_overlay_color`][flet.SearchBar.bar_overlay_color] in all
2888+
descendant [`SearchBar`][flet.SearchBar] controls.
2889+
"""
2890+
28792891
elevation: Optional[ControlStateValue[Optional[Number]]] = None
2892+
"""
2893+
Overrides the default value of
2894+
[`SearchBar.bar_elevation`][flet.SearchBar.bar_elevation] in all descendant
2895+
[`SearchBar`][flet.SearchBar] controls.
2896+
"""
2897+
28802898
text_style: Optional[ControlStateValue[TextStyle]] = None
2899+
"""
2900+
Overrides the default value of
2901+
[`SearchBar.bar_text_style`][flet.SearchBar.bar_text_style] in all descendant
2902+
[`SearchBar`][flet.SearchBar] controls.
2903+
"""
2904+
28812905
hint_style: Optional[ControlStateValue[TextStyle]] = None
2906+
"""
2907+
Overrides the default value of
2908+
[`SearchBar.bar_hint_style`][flet.SearchBar.bar_hint_style] in all descendant
2909+
[`SearchBar`][flet.SearchBar] controls.
2910+
"""
2911+
28822912
shape: Optional[ControlStateValue[OutlinedBorder]] = None
2913+
"""
2914+
Overrides the default value of
2915+
[`SearchBar.bar_shape`][flet.SearchBar.bar_shape] in all descendant
2916+
[`SearchBar`][flet.SearchBar] controls.
2917+
"""
2918+
28832919
padding: Optional[ControlStateValue[PaddingValue]] = None
2920+
"""
2921+
Overrides the default value of
2922+
[`SearchBar.bar_padding`][flet.SearchBar.bar_padding] in all descendant
2923+
[`SearchBar`][flet.SearchBar] controls.
2924+
"""
2925+
28842926
size_constraints: Optional[BoxConstraints] = None
2927+
"""
2928+
Overrides the default value of
2929+
[`SearchBar.size_constraints`][flet.SearchBar.size_constraints] in all descendant
2930+
[`SearchBar`][flet.SearchBar] controls.
2931+
"""
2932+
28852933
border_side: Optional[ControlStateValue[BorderSide]] = None
2934+
"""
2935+
Overrides the default value of
2936+
[`SearchBar.bar_border_side`][flet.SearchBar.bar_border_side] in all
2937+
descendant [`SearchBar`][flet.SearchBar] controls.
2938+
"""
28862939

28872940

28882941
@dataclass

0 commit comments

Comments
 (0)