That is a Component File and i need help with that:
Widget defaultTextFormField({
required TextEditingController controller,
required TextInputType keyboardtype,
required Function () submitFunction,
required Function validator,
required IconData prefix,
ValueChanged<String>? onchange,
String labelText = 'Enter Text ...',
}) => TextFormField(
controller: controller,
keyboardType: keyboardtype,
decoration: InputDecoration(
labelText: labelText,
prefixIcon: prefix,
border: OutlineInputBorder(),
),
onFieldSubmitted: submitFunction(),
onChanged: onchange,
validator: validator(),
);
Try to fix my code problem . expected to find help with that.
CodePudding user response:
The validator
has been defined like
typedef FormFieldValidator<T> = String? Function(T? value);
It should return nullable data and provide value on callback. You can use
required FormFieldValidator validator,
It will be same as required String Function(String?) validator,
and use like validator: validator,
Widget defaultTextFormField({
required TextEditingController controller,
required TextInputType keyboardtype,
required Function(String?) submitFunction,
required FormFieldValidator validator,
required Widget prefix,
ValueChanged<String>? onchange,
String labelText = 'Enter Text ...',
}) =>
TextFormField(
controller: controller,
keyboardType: keyboardtype,
decoration: InputDecoration(
labelText: labelText,
prefixIcon: prefix,
border: OutlineInputBorder(),
),
onFieldSubmitted: submitFunction(),
onChanged: onchange,
validator: validator,
);