import 'package:flutter/material.dart'; class GenderDropdown extends StatefulWidget { final Function(String) onChanged; const GenderDropdown({super.key, required this.onChanged}); @override State createState() => _GenderDropdownState(); } class _GenderDropdownState extends State { String? selectedGender; @override Widget build(BuildContext context) { return InputDecorator( decoration: InputDecoration( border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), ), prefixIcon: const Icon(Icons.groups), contentPadding: const EdgeInsets.symmetric( horizontal: 12.0, vertical: 7.0, ), ), child: DropdownButtonHideUnderline( child: DropdownButton( isExpanded: true, value: selectedGender, hint: const Text( 'Selecciona tu género', style: TextStyle(fontSize: 16.0), ), onChanged: (String? newValue) { setState(() { selectedGender = newValue; widget.onChanged(selectedGender!); }); }, items: ['Masculino', 'Femenino', 'Otro'] .map>((String value) { return DropdownMenuItem( value: value, child: Text(value), ); }).toList(), ), ), ); } }