import 'archivo_adjunto.dart'; import 'gps_location.dart'; class Contenedor { final String hash; final String? titulo; final String? descripcion; final List archivos; final GpsLocation? gps; final List etiquetas; final DateTime createdAt; Contenedor({ required this.hash, this.titulo, this.descripcion, List? archivos, this.gps, List? etiquetas, DateTime? createdAt, }) : archivos = archivos ?? [], etiquetas = etiquetas ?? [], createdAt = createdAt ?? DateTime.now(); Contenedor copyWith({ String? hash, String? titulo, String? descripcion, List? archivos, GpsLocation? gps, List? 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 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; }