0

Here's the snippet for the dropdown items widgets:

items:
categoryList
    .map((item) => DropdownMenuItem<String>(
          value: item,
          child: Text(
            item,
            style: const TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.normal,
              color: Colors.white,
            ),
            overflow: TextOverflow.ellipsis,
          ),
        ))
    .toList(),
value: widget.categoryValue,
onChanged: widget.onChanged,

Here's the code for the dropdown button form field.

DropdownButtonFormField(
      decoration: const InputDecoration(
        labelText: 'Excercise Body Part',
      ),
      items: const [
        DropdownMenuItem(
          value: BodyPart.chest,
          child: Text('Chest'),
        ),
        DropdownMenuItem(
          value: BodyPart.back,
          child: Text('Back'),
        ),
        
      ],
      onChanged: (value) => {_bodyPart = value!},
    ),
  ],
),

I want to return the value to an enum instead of returning it as a String.

user16217248
  • 3,119
  • 19
  • 19
  • 37
jhonny
  • 1

0 Answers0