Widget build()

in components/frontend_flutterflow/src/lib/flutter_flow/flutter_flow_drop_down.dart [77:129]


  Widget build(BuildContext context) {
    final value = widget.options.contains(widget.controller.value)
        ? widget.controller.value
        : null;
    final items = widget.options
        .asMap()
        .entries
        .map(
          (option) => DropdownMenuItem<T>(
            value: option.value,
            child: Text(
              widget.optionLabels == null ||
                      widget.optionLabels!.length < option.key + 1
                  ? option.value.toString()
                  : widget.optionLabels![option.key],
              style: widget.textStyle,
            ),
          ),
        )
        .toList();
    final hintText = widget.hintText != null
        ? Text(widget.hintText!, style: widget.textStyle)
        : null;
    void Function(T?)? onChanged =
        !widget.disabled ? (value) => widget.controller.value = value : null;
    final dropdownWidget = widget.isSearchable
        ? _buildSearchableDropdown(value, items, onChanged, hintText)
        : _buildNonSearchableDropdown(value, items, onChanged, hintText);
    final childWidget = DecoratedBox(
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(widget.borderRadius),
        border: Border.all(
          color: widget.borderColor,
          width: widget.borderWidth,
        ),
        color: widget.fillColor,
      ),
      child: Padding(
        padding: widget.margin,
        child: widget.hidesUnderline
            ? DropdownButtonHideUnderline(child: dropdownWidget)
            : dropdownWidget,
      ),
    );
    if (widget.height != null || widget.width != null) {
      return Container(
        width: widget.width,
        height: widget.height,
        child: childWidget,
      );
    }
    return childWidget;
  }