2024-05-30 01:10:53 +02:00
|
|
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
|
|
|
2024-05-05 01:02:09 +02:00
|
|
|
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<String, dynamic> toMap() {
|
|
|
|
return {
|
|
|
|
'code': code,
|
|
|
|
'name': name,
|
|
|
|
'nativeName': nativeName,
|
|
|
|
'iconFile': iconFile,
|
|
|
|
};
|
|
|
|
}
|
2024-05-06 15:21:21 +02:00
|
|
|
|
2024-05-30 01:10:53 +02:00
|
|
|
factory Language.fromDocument(DocumentSnapshot doc) {
|
|
|
|
Map<String, dynamic> data = doc.data() as Map<String, dynamic>;
|
|
|
|
return Language(
|
|
|
|
code: data['code'] ?? '',
|
|
|
|
name: data['name'] ?? '',
|
|
|
|
nativeName: data['nativeName'] ?? '',
|
|
|
|
iconFile: data['iconFile'] ?? '',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-05-06 15:21:21 +02:00
|
|
|
@override
|
|
|
|
int get hashCode => code.hashCode;
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool operator ==(Object other) => other is Language && code == other.code;
|
2024-05-05 01:02:09 +02:00
|
|
|
}
|