before rediense

This commit is contained in:
Felipe
2024-02-26 14:46:26 -05:00
parent 37b6665002
commit a1e367bdf3
10 changed files with 341 additions and 164 deletions
@@ -1,50 +0,0 @@
import 'package:flutter/material.dart';
class BirthDatePicker extends StatefulWidget {
final Function(DateTime) onDateSelected;
final TextEditingController controller;
const BirthDatePicker(
{Key? key, required this.onDateSelected, required this.controller})
: super(key: key);
@override
_BirthDatePickerState createState() => _BirthDatePickerState();
}
class _BirthDatePickerState extends State<BirthDatePicker> {
DateTime selectedDate =
DateTime.now().subtract(const Duration(days: 365 * 20));
Future<void> _selectDate(BuildContext context) async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: selectedDate,
firstDate: DateTime.now().subtract(const Duration(days: 365 * 120)),
lastDate: DateTime.now(),
);
if (picked != null && picked != selectedDate) {
setState(() {
selectedDate = picked;
widget.onDateSelected(selectedDate);
});
}
}
@override
Widget build(BuildContext context) {
return TextFormField(
onTap: () {
_selectDate(context);
},
readOnly: true,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.calendar_month),
suffixIcon: Icon(Icons.arrow_drop_down),
hintText: 'Fecha de nacimiento',
),
controller: widget.controller,
);
}
}
@@ -1,45 +0,0 @@
import 'package:flutter/material.dart';
class GenderDropdown extends StatefulWidget {
final Function(String) onChanged;
const GenderDropdown({Key? key, required this.onChanged}) : super(key: key);
@override
_GenderDropdownState createState() => _GenderDropdownState();
}
class _GenderDropdownState extends State<GenderDropdown> {
String? selectedGender;
@override
Widget build(BuildContext context) {
return InputDecorator(
decoration: const InputDecoration(
border: UnderlineInputBorder(),
prefixIcon: Icon(Icons.people_outline),
contentPadding: EdgeInsets.symmetric(horizontal: 8.0),
),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
isExpanded: true,
value: selectedGender,
hint: const Text('Selecciona tu género'),
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(),
),
),
);
}
}