Skip to content

Commit 4363c91

Browse files
committed
Enable RenderedLayoutModel for buttons and dropdowns.
1 parent 8cb71b4 commit 4363c91

File tree

1 file changed

+49
-40
lines changed

1 file changed

+49
-40
lines changed

lib/src/transformers/node_transformers/passive_dropdown_transformer.dart

Lines changed: 49 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -188,46 +188,55 @@ class PassiveDropdownWidget extends StatelessWidget {
188188
hoverColor: node.properties.hoverColor?.toFlutterColor(),
189189
splashColor: node.properties.splashColor?.toFlutterColor(),
190190
),
191-
child: DropdownButton<Object>(
192-
value: items.isEmpty || items.count(value) != 1 ? null : value,
193-
isDense: node.properties.dense,
194-
isExpanded: node.properties.expanded,
195-
autofocus: node.properties.autoFocus,
196-
enableFeedback: node.properties.enableFeedback,
197-
alignment:
198-
node.properties.selectedItemAlignment.flutterAlignmentGeometry ??
199-
Alignment.centerLeft,
200-
hint: node.properties.hint.isNotEmpty
201-
? Text(
202-
node.properties.hint,
203-
style: TextUtils.retrieveTextStyleFromProp(
204-
node.properties.hintStyle,
205-
),
206-
overflow: TextOverflow.ellipsis,
207-
)
208-
: null,
209-
iconDisabledColor: node.properties.iconDisabledColor.toFlutterColor(),
210-
iconEnabledColor: node.properties.iconEnabledColor.toFlutterColor(),
211-
iconSize: node.properties.iconSize,
212-
icon: retrieveIconWidget(
213-
node.properties.icon, node.properties.iconSize),
214-
dropdownColor: node.properties.dropdownColor.toFlutterColor(),
215-
focusColor: node.properties.focusColor.toFlutterColor(),
216-
elevation: node.properties.elevation,
217-
borderRadius: node.properties.borderRadius.borderRadius,
218-
onTap: onTap,
219-
padding: node.padding.flutterEdgeInsets,
220-
onChanged: node.properties.enabled
221-
? (value) {
222-
if (value == null) return;
223-
final index = items.indexOf(value);
224-
onChanged?.call(index, value);
225-
}
226-
: null,
227-
underline: node.properties.underline ? null : const SizedBox.shrink(),
228-
items: buildItems(context, items),
229-
selectedItemBuilder: (context) => selectedItemBuilder(context, items),
230-
),
191+
child: Builder(builder: (context) {
192+
final child = DropdownButton<Object>(
193+
value: items.isEmpty || items.count(value) != 1 ? null : value,
194+
isDense: node.properties.dense,
195+
isExpanded: node.properties.expanded,
196+
autofocus: node.properties.autoFocus,
197+
enableFeedback: node.properties.enableFeedback,
198+
alignment: node.properties.selectedItemAlignment
199+
.flutterAlignmentGeometry ??
200+
Alignment.centerLeft,
201+
hint: node.properties.hint.isNotEmpty
202+
? Text(
203+
node.properties.hint,
204+
style: TextUtils.retrieveTextStyleFromProp(
205+
node.properties.hintStyle,
206+
),
207+
overflow: TextOverflow.ellipsis,
208+
)
209+
: null,
210+
iconDisabledColor:
211+
node.properties.iconDisabledColor.toFlutterColor(),
212+
iconEnabledColor: node.properties.iconEnabledColor.toFlutterColor(),
213+
iconSize: node.properties.iconSize,
214+
icon: retrieveIconWidget(
215+
node.properties.icon, node.properties.iconSize),
216+
dropdownColor: node.properties.dropdownColor.toFlutterColor(),
217+
focusColor: node.properties.focusColor.toFlutterColor(),
218+
elevation: node.properties.elevation,
219+
borderRadius: node.properties.borderRadius.borderRadius,
220+
onTap: onTap,
221+
padding: node.padding.flutterEdgeInsets,
222+
onChanged: node.properties.enabled
223+
? (value) {
224+
if (value == null) return;
225+
final index = items.indexOf(value);
226+
onChanged?.call(index, value);
227+
}
228+
: null,
229+
underline:
230+
node.properties.underline ? null : const SizedBox.shrink(),
231+
items: buildItems(context, items),
232+
selectedItemBuilder: (context) =>
233+
selectedItemBuilder(context, items),
234+
);
235+
if (node.horizontalFit.isWrap) {
236+
return IntrinsicWidth(child: child);
237+
}
238+
return child;
239+
}),
231240
),
232241
);
233242
}

0 commit comments

Comments
 (0)