feat(favorites): add group persistence foundation
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
class GrupoFavoritos {
|
||||
const GrupoFavoritos({
|
||||
required this.id,
|
||||
required this.nombre,
|
||||
required this.orden,
|
||||
this.protegido = false,
|
||||
});
|
||||
|
||||
static const sinAsignarId = 'sin_asignar';
|
||||
|
||||
final String id;
|
||||
final String nombre;
|
||||
final int orden;
|
||||
final bool protegido;
|
||||
|
||||
bool get esSinAsignar => id == sinAsignarId;
|
||||
|
||||
factory GrupoFavoritos.fromMap(Map<String, dynamic> map) {
|
||||
return GrupoFavoritos(
|
||||
id: map['id'] as String,
|
||||
nombre: map['nombre'] as String,
|
||||
orden: map['orden'] as int? ?? 0,
|
||||
protegido: (map['protegido'] as int? ?? 0) == 1,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return {
|
||||
'id': id,
|
||||
'nombre': nombre,
|
||||
'orden': orden,
|
||||
'protegido': protegido ? 1 : 0,
|
||||
};
|
||||
}
|
||||
|
||||
GrupoFavoritos copyWith({
|
||||
String? id,
|
||||
String? nombre,
|
||||
int? orden,
|
||||
bool? protegido,
|
||||
}) {
|
||||
return GrupoFavoritos(
|
||||
id: id ?? this.id,
|
||||
nombre: nombre ?? this.nombre,
|
||||
orden: orden ?? this.orden,
|
||||
protegido: protegido ?? this.protegido,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user