Files
packet/lib/domain/entities/contenedor.dart

56 lines
1.5 KiB
Dart
Raw Normal View History

import 'archivo_adjunto.dart';
import 'gps_location.dart';
class Contenedor {
final String hash;
final String? titulo;
final String? descripcion;
final List<ArchivoAdjunto> archivos;
final GpsLocation? gps;
final List<String> etiquetas;
final DateTime createdAt;
Contenedor({
required this.hash,
this.titulo,
this.descripcion,
List<ArchivoAdjunto>? archivos,
this.gps,
List<String>? etiquetas,
DateTime? createdAt,
}) : archivos = archivos ?? [],
etiquetas = etiquetas ?? [],
createdAt = createdAt ?? DateTime.now();
Contenedor copyWith({
String? hash,
String? titulo,
String? descripcion,
List<ArchivoAdjunto>? archivos,
GpsLocation? gps,
List<String>? etiquetas,
DateTime? createdAt,
}) =>
Contenedor(
hash: hash ?? this.hash,
titulo: titulo ?? this.titulo,
descripcion: descripcion ?? this.descripcion,
archivos: archivos ?? this.archivos,
gps: gps ?? this.gps,
etiquetas: etiquetas ?? this.etiquetas,
createdAt: createdAt ?? this.createdAt,
);
Map<String, dynamic> toJson() => {
'hash': hash,
if (titulo != null) 'titulo': titulo,
if (descripcion != null) 'descripcion': descripcion,
'etiquetas': etiquetas,
if (gps != null) 'gps': gps!.toJson(),
'archivos': archivos.map((a) => a.toJson()).toList(),
};
bool get isEmpty => archivos.isEmpty && etiquetas.isEmpty && titulo == null;
int get archivoCount => archivos.length;
}