0

I'm trying to send the DropDownButton selected values to EmailJS. I'm using TextEditingController for TextFormField and it's working fine and the values taken by EmailJS. How I can send the DropDownButton values whichcontroller I can use in Flutter.

Padding(
  padding: EdgeInsets.all(20),
  child: Container(
    decoration: BoxDecoration(
      borderRadius: BorderRadius.circular(0),
      border: Border.all(
        color: Colors.black12,
        width: 1
      ),
    ),
    child: Padding(
      padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
      child: DropdownButton<String>(
        hint: Text('Select Service',
          style: TextStyle(
            fontFamily:'D-Din',
            fontSize: 20,
            fontWeight: FontWeight.bold,
            color: Colors.black45
          ),
        ),
        value: dropdownValue,
        iconSize: 30,
        icon: Icon(
          Icons.arrow_drop_down,
          color: Colors.black45,
        ),
        isExpanded: true,
        items: items.map(buildMenuItem).toList(),
        onChanged: (value) => setState(() => this.dropdownValue = value),
      ),
    ),
  ),
),

I have to send the values.

1 Answers1

0

I tried this way and It's sending data now.

I pass the value of the drop box with this way in onpressed.

service: dropdownValue.toString(),

and call the class variable.

String? dropdownValue;

final dropdownValueKey = GlobalKey<FormState>();

that's it.