-2
I have a field that is for "date of birth" Textformfield and I have a mask to facilitate user typing (dd/mm/yyyy) but I need a validation that, depending on what the user type is not possible to register him being under 18 and above 70 years of age and in case this verification would be for when the user click the button register for example.
FractionallySizedBox(
widthFactor: 0.9,
child: Container(
width: MediaQuery
.of(context)
.size
.width / 1,
height: 50,
child: TextFormField(
controller: dateController,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly,
DataInputFormatter(),
],
validator: (value) {
if (value == null || value.isEmpty) {
return '';
}
return null;
},
decoration: InputDecoration(
errorStyle: TextStyle(
fontSize: 0.0,
),
prefixIcon: Icon(
Icons.calendar_today_outlined,
color: darkGreenColor,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
labelText: 'Data de Nascimento*',
labelStyle: TextStyle(color: Colors.black26)),
)
),
),