54 lines
1.4 KiB
Dart
54 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class GenderDropdown extends StatefulWidget {
|
|
final Function(String) onChanged;
|
|
|
|
const GenderDropdown({super.key, required this.onChanged});
|
|
|
|
@override
|
|
State<GenderDropdown> createState() => _GenderDropdownState();
|
|
}
|
|
|
|
class _GenderDropdownState extends State<GenderDropdown> {
|
|
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<String>(
|
|
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<DropdownMenuItem<String>>((String value) {
|
|
return DropdownMenuItem<String>(
|
|
value: value,
|
|
child: Text(value),
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|