@@ -21,9 +21,15 @@ class DropdownNode extends SceneNode with CustomPropertiesMixin {
2121 @override
2222 final String type = 'dropdown' ;
2323
24+ @override
25+ bool get supportsPadding => true ;
26+
2427 /// Holds configurable properties of the dropdown.
2528 DropdownProperties properties;
2629
30+ /// Index of the selected option in the dropdown.
31+ int ? value;
32+
2733 /// Creates a [DropdownNode] with the given data.
2834 DropdownNode ({
2935 required super .id,
@@ -45,12 +51,19 @@ class DropdownNode extends SceneNode with CustomPropertiesMixin {
4551 super .aspectRatioLock,
4652 super .positioningMode,
4753 required this .properties,
54+ this .value,
4855 });
4956
5057 @override
5158 List <TriggerType > get triggerTypes =>
5259 [TriggerType .click, TriggerType .changed];
5360
61+ @override
62+ late final List <ValueModel > propertyVariables = [
63+ ...super .propertyVariables,
64+ IntValue (name: 'value' , value: value ?? - 1 ),
65+ ];
66+
5467 @override
5568 BoxConstraintsModel internalConstraints ({
5669 required SizeFit horizontalFit,
@@ -75,9 +88,6 @@ class DropdownNode extends SceneNode with CustomPropertiesMixin {
7588/// Holds configurable properties of the dropdown.
7689@JsonSerializable ()
7790class DropdownProperties with SerializableMixin , EquatableMixin {
78- /// Index of the selected option in the dropdown.
79- int value;
80-
8191 /// Whether the dropdown is in the enabled state.
8292 bool enabled;
8393
@@ -94,7 +104,7 @@ class DropdownProperties with SerializableMixin, EquatableMixin {
94104 /// tapped or long pressed.
95105 bool enableFeedback;
96106
97- /// Dropdown's options.
107+ /// Dropdown options.
98108 final List <String > items;
99109
100110 /// Text style applied to the dropdown's options.
@@ -143,9 +153,15 @@ class DropdownProperties with SerializableMixin, EquatableMixin {
143153 /// Whether to underline dropdown button's contents.
144154 bool underline;
145155
156+ /// Whether to use data source to populate dropdown options.
157+ bool useDataSource;
158+
159+ /// Label of the data source to use. This is only used when [useDataSource]
160+ /// is true. Allows to specify a template for item builder.
161+ String itemLabel;
162+
146163 /// Creates a [DropdownProperties] instance with the given data.
147164 DropdownProperties ({
148- this .value = 0 ,
149165 this .enabled = true ,
150166 this .dense = false ,
151167 this .expanded = false ,
@@ -167,6 +183,8 @@ class DropdownProperties with SerializableMixin, EquatableMixin {
167183 this .elevation = 8 ,
168184 this .borderRadius = CornerRadius .zero,
169185 this .underline = true ,
186+ this .useDataSource = false ,
187+ this .itemLabel = '' ,
170188 }) : itemTextStyle = itemTextStyle ??
171189 TextProp .general (
172190 fills: [PaintModel .blackPaint],
@@ -205,6 +223,8 @@ class DropdownProperties with SerializableMixin, EquatableMixin {
205223 int ? elevation,
206224 CornerRadius ? borderRadius,
207225 bool ? underline,
226+ bool ? useDataSource,
227+ String ? itemLabel,
208228 }) {
209229 return DropdownProperties (
210230 items: items ?? this .items,
@@ -225,6 +245,8 @@ class DropdownProperties with SerializableMixin, EquatableMixin {
225245 elevation: elevation ?? this .elevation,
226246 borderRadius: borderRadius ?? this .borderRadius,
227247 underline: underline ?? this .underline,
248+ useDataSource: useDataSource ?? this .useDataSource,
249+ itemLabel: itemLabel ?? this .itemLabel,
228250 );
229251 }
230252
@@ -245,6 +267,9 @@ class DropdownProperties with SerializableMixin, EquatableMixin {
245267 focusColor,
246268 elevation,
247269 borderRadius,
270+ underline,
271+ useDataSource,
272+ itemLabel,
248273 ];
249274
250275 /// Creates a [DropdownProperties] instance from a JSON object.
0 commit comments