I have a normal class like this

  class University implements BaseResponseContract {
  final String? name;
  final int? id;
  University({required this.id, required this.name});

  factory University.fromJson(Map<String, dynamic> json) => _$UniversityFromJson(json);
  Map<String, dynamic> toJson() => _$UniversityToJson(this);

and this is BaseResponseContract

   abstract class BaseResponseContract<T> {
  factory T.fromJson(Map<String, dynamic> json);

This gives an error now, I want to correct and

I want to build a general Firebase class to read datas so that I dont have to write from scratch everytime,

  abstract class IFirebaseEntity<T> {
  final String collectionName;
  late final instance;

  IFirebaseEntity(this.collectionName) {
    instance = FirebaseFirestore.instance.collection(collectionName)
    .withConverter(fromFirestore: (snapshot,_)=>**T.fromJson(snapshot)**, toFirestore: toFirestore);

However it doesn't work. It doesn't recognize T.fromJson() method, I want to build a Firebase Entity class to build such a functionality that, I will extend with a T and will be able to use that firebase class generated by the abstract class.

This is an example that extends this FirebaseEntity

    class ReadUnivercities extends IFirebaseEntity<University> {
  ReadUnivercities(String collectionName) : super(collectionName);