I am little confused while writing a simple class as below:
class NewsSource {
final String url;
final String name;
final String imageUrl;
NewsSource({required this.url, required this.name, required this.imageUrl});
factory NewsSource.fromFireStore(
DocumentSnapshot<Map<String, dynamic>> snapshot,
SnapshotOptions? options) {
final data = snapshot.data();
return NewsSource(
url: data?['url'], name: data?['name'], imageUrl: data?['imageUrl']);
}
Map<String, dynamic> toFireStore() {
return {"url": url, "name": name, "imageUrl": imageUrl};
}
}
fromFireStore function call NewsSource constructor where parameters can be null clearly but still dart is not complaining why?
PS: If I remove dynamic then it starts to complain, I guess any use of dynamic makes null check redundant.