convert DocumentSnap shot object to Mapflutter

Solution for convert DocumentSnap shot object to Mapflutter
is Given Below:

I want to convert Firestore DocumentSnap shot object to Map<String, dynamic> but it gives an error.

The argument type ‘Object’ can’t be assigned to the parameter type ‘Map<String, dynamic>’.

factory LedgerMaster.fromDocument(DocumentSnapshot doc) {
final data = doc.data()!;
return LedgerMaster.fromJson(data).copyWith(id: doc.id);
}

final data = doc.data() as Map<String, dynamic>;