buildDropDown method

Widget buildDropDown(
  1. BuildContext context
)

Implementation

Widget buildDropDown(BuildContext context) {
  String? title = widget.schema["title"];
  dynamic description = widget.schema["description"];
  bool multiple = widget.options?["multiple"] == true;

  return Column(
    children: [
      multiple
          ? MultiSelectDialogField(
              items:
                  widget.enumeration!.map<MultiSelectItem>((String element) {
                return MultiSelectItem(element, element);
              }).toList(),
              initialValue: values,
              title: widget.schema["title"] != null
                  ? Text(widget.schema["title"])
                  : null,
              buttonText: widget.schema["title"] != null
                  ? Text(
                      widget.schema["title"],
                      style: TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.w100,
                        color: Color(0xFF888888),
                      ),
                    )
                  : null,
              listType: MultiSelectListType.LIST,
              searchable: true,
              onConfirm: (values) {
                onValueChanged(values);
              },
            )
          : DropdownButton<String>(
              value: value,
              hint: Text(title ?? "Select"),
              icon: const Icon(Icons.arrow_drop_down),
              iconSize: 32,
              isExpanded: true,
              itemHeight: 56,
              underline: Container(
                height: 2,
                decoration: BoxDecoration(
                  border: Border.all(color: const Color(0xFFBDBDBD)),
                ),
              ),
              onChanged: widget.options?["readonly"] == true
                  ? null
                  : (String? val) {
                      onValueChanged(val ?? "");
                    },
              items: widget.enumeration!
                  .map<DropdownMenuItem<String>>((String element) {
                return DropdownMenuItem<String>(
                  value: element,
                  child: Text(
                    element,
                    style: const TextStyle(fontSize: 16),
                  ),
                );
              }).toList(),
            ),
      description != null ? const SizedBox(height: 8) : Container(),
      description != null
          ? MarkdownBody(
              data: description["text"],
              onTapLink: (text, href, title) {
                launchUrl(Uri.parse(href!));
              },
              styleSheet: MarkdownStyleSheet.fromTheme(Theme.of(context))
                  .copyWith(
                      p: Theme.of(context)
                          .textTheme
                          .headline1
                          ?.copyWith(fontSize: description["size"] ?? 14.0)),
            )
          : Container(),
    ],
  );
}