Saturday 26 January 2019

select box flutter

FormField(
        initialValue: initialValue,
        builder: (FormFieldState state) {
          return InputDecorator(
            decoration: InputDecoration(
              labelText: Translations.of(context).text(label),
            ),
            child: DropdownButtonHideUnderline(
              child: DropdownButton(
                value: selectBoxvalue ?? null,
                items: dropDownList.toList(),
                onChanged: (value) {
                  setState(() {
                    selectBoxvalue = value;
                  });

                  if (controller != null) {
                    controller.text = value;
                  }

                  if (onChangeSelectMap != null) {
                    onChangeSelectMap(value);
                  }
                },
              ),
            ),
          );
        });


///////////////////////////

map.forEach((k, v) {
      dropDownList.add(DropdownMenuItem(
        value: k,
        child: new Text(v),
      ));
    });
////////////////////////////////

No comments:

Post a Comment