render method
Widget
render(
- DropdownButton element,
- BuildContext context,
- FormElementEventDispatcherFunction dispatcher,
- FormElementRendererFunction<
FormElement> renderer,
Implementation
@override
Widget render(
model.DropdownButton element,
BuildContext context,
FormElementEventDispatcherFunction dispatcher,
FormElementRendererFunction renderer) {
return LazyStreamBuilder(
streamFactory: () => MergeStream([
...element.choices.map((o) => o.isVisibleChanged),
element.propertyChanged,
]),
builder: (context, _) {
return Center(
child: DropdownButton<String>(
value: element.value,
onChanged: (String? newValue) => dispatcher(
ChangeValueEvent(
value: newValue,
elementId: element.id!,
propertyName: model.SingleSelectGroup.valuePropertyName),
),
items: element.choices
.where((d) => d.isVisible)
.whereType<model.DropdownOption>()
.map<DropdownMenuItem<String>>(
(model.DropdownOption option) {
return DropdownMenuItem<String>(
value: option.value,
child: Text(option.label),
);
},
).toList(),
),
);
},
);
}