toWidget method

  1. @override
Widget toWidget(
  1. BuildContext context,
  2. String group,
  3. T? value
)
override

Builds the current field into a Widget to be used for input in the side panel.

Implementation

@override
Widget toWidget(BuildContext context, String group, T? value) {
  return DropdownMenu<T>(
    expandedInsets: EdgeInsets.zero,
    trailingIcon: const Icon(Icons.keyboard_arrow_down_rounded),
    selectedTrailingIcon: const Icon(Icons.keyboard_arrow_up_rounded),
    initialSelection: value,
    onSelected: (value) {
      if (value != null) {
        updateField(context, group, value);
      }
    },
    dropdownMenuEntries: values
        .map(
          (value) => DropdownMenuEntry(
            value: value,
            label: labelBuilder(value),
          ),
        )
        .toList(),
  );
}