I have a variable defined as type:-
final Future Function(BuildContext context, FormModel model) onSubmitCallBack;
I am assigning to it a function which takes 2 parameters of type BuildContext and Institute, and returns Future.
Note that Institute is a Subclass of FormModel.
There is no error at compile time. But at runtime I get this error.
Expected a value of type '(BuildContext, FormModel) => Future', but got one of type '(BuildContext, Institute) => Future'
Any Ideas why? I expected this to run since Institute is subclass of FormModel.
The FormModel and Institute class:
class FormModel{
const FormModel();
}
class Institute extends FormModel {
final int? id;
final String name;
final String? addedOn;
final String? updateOn;
const Institute({
this.id,
required this.name,
this.addedOn,
this.updateOn
});
}