Skip to content

Commit 7cf793f

Browse files
Added dense property to TextField and Dropdown controls (#696)
Close #690
1 parent 715f162 commit 7cf793f

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

package/lib/src/controls/form_field.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ InputDecoration buildInputDecoration(BuildContext context, Control control,
107107

108108
return InputDecoration(
109109
contentPadding: parseEdgeInsets(control, "contentPadding"),
110+
isDense: control.attrBool("dense"),
110111
label: label != "" ? Text(label) : null,
111112
labelStyle: parseTextStyle(Theme.of(context), control, "labelStyle"),
112113
border: border,

sdk/python/flet/dropdown.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class Dropdown(FormFieldControl):
2323
"""
2424
A dropdown lets the user select from a number of items. The dropdown shows the currently selected item as well as an arrow that opens a menu for selecting another item.
25-
25+
2626
Example:
2727
```
2828
import flet as ft
@@ -51,6 +51,7 @@ def button_clicked(e):
5151
5252
Online docs: https://flet.dev/docs/controls/dropdown
5353
"""
54+
5455
def __init__(
5556
self,
5657
ref: Optional[Ref] = None,
@@ -93,6 +94,7 @@ def __init__(
9394
focused_border_width: OptionalNumber = None,
9495
focused_border_color: Optional[str] = None,
9596
content_padding: PaddingValue = None,
97+
dense: Optional[bool] = None,
9698
filled: Optional[bool] = None,
9799
hint_text: Optional[str] = None,
98100
hint_style: Optional[TextStyle] = None,
@@ -163,6 +165,7 @@ def __init__(
163165
focused_border_width=focused_border_width,
164166
focused_border_color=focused_border_color,
165167
content_padding=content_padding,
168+
dense=dense,
166169
filled=filled,
167170
hint_text=hint_text,
168171
hint_style=hint_style,

sdk/python/flet/form_field_control.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def __init__(
7878
focused_border_width: OptionalNumber = None,
7979
focused_border_color: Optional[str] = None,
8080
content_padding: PaddingValue = None,
81+
dense: Optional[bool] = None,
8182
filled: Optional[bool] = None,
8283
hint_text: Optional[str] = None,
8384
hint_style: Optional[TextStyle] = None,
@@ -142,6 +143,7 @@ def __init__(
142143
self.focused_border_color = focused_border_color
143144
self.content_padding = content_padding
144145
self.filled = filled
146+
self.dense = dense
145147
self.hint_text = hint_text
146148
self.hint_style = hint_style
147149
self.helper_text = helper_text
@@ -341,6 +343,15 @@ def content_padding(self) -> PaddingValue:
341343
def content_padding(self, value: PaddingValue):
342344
self.__content_padding = value
343345

346+
# dense
347+
@property
348+
def dense(self) -> Optional[bool]:
349+
return self._get_attr("dense")
350+
351+
@dense.setter
352+
def dense(self, value: Optional[bool]):
353+
self._set_attr("dense", value)
354+
344355
# filled
345356
@property
346357
def filled(self) -> Optional[bool]:

sdk/python/flet/textfield.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class TextCapitalization(Enum):
6868
class TextField(FormFieldControl):
6969
"""
7070
A text field lets the user enter text, either with hardware keyboard or with an onscreen keyboard.
71-
71+
7272
Example:
7373
```
7474
import flet as ft
@@ -94,6 +94,7 @@ def button_clicked(e):
9494
9595
Online docs: https://flet.dev/docs/controls/textfield
9696
"""
97+
9798
def __init__(
9899
self,
99100
ref: Optional[Ref] = None,
@@ -136,6 +137,7 @@ def __init__(
136137
focused_border_width: OptionalNumber = None,
137138
focused_border_color: Optional[str] = None,
138139
content_padding: PaddingValue = None,
140+
dense: Optional[bool] = None,
139141
filled: Optional[bool] = None,
140142
hint_text: Optional[str] = None,
141143
hint_style: Optional[TextStyle] = None,
@@ -221,6 +223,7 @@ def __init__(
221223
focused_border_width=focused_border_width,
222224
focused_border_color=focused_border_color,
223225
content_padding=content_padding,
226+
dense=dense,
224227
filled=filled,
225228
hint_text=hint_text,
226229
hint_style=hint_style,

0 commit comments

Comments
 (0)