I need to create a shared component but this error appears
<The argument type 'Function?' can't be assigned to the parameter type 'void Function(String)?>
although I changed Function type into VoidCallback
type but it didn't work,
please help
Widget defaultFormField({
required TextEditingController controller,
required String label,
required TextInputType type,
required VoidCallback validate,
Function? onSubmit,
required IconData prefix}) =>
onFieldSubmitted: onSubmit,
validator: validate,
controller: controller,
keyboardType: type,
);
CodePudding user response:
You need to pass onSubmit
as Function(String)?
. Try this:
Widget defaultFormField({
required TextEditingController controller,
required String label,
required TextInputType type,
required VoidCallback validate,
Function(String)? onSubmit,
required IconData prefix}) =>
onFieldSubmitted: onSubmit,
validator: validate,
controller: controller,
keyboardType: type,
);
CodePudding user response:
Change Function?
into Function(String)?