import 'package:cloud_firestore/cloud_firestore.dart'; class Language { final String code; final String name; final String nativeName; final String iconFile; Language({ required this.code, required this.name, required this.nativeName, required this.iconFile, }); // convert to a map Map toMap() { return { 'code': code, 'name': name, 'nativeName': nativeName, 'iconFile': iconFile, }; } factory Language.fromDocument(DocumentSnapshot doc) { Map data = doc.data() as Map; return Language( code: data['code'] ?? '', name: data['name'] ?? '', nativeName: data['nativeName'] ?? '', iconFile: data['iconFile'] ?? '', ); } @override int get hashCode => code.hashCode; @override bool operator ==(Object other) => other is Language && code == other.code; }