/// Modelo de datos de una emisora de radio. /// /// Representa una emisora favorita almacenada en SQLite. /// Los campos opcionales (favicon, pais, idioma, tags) pueden ser null /// cuando la emisora no dispone de esa información. class Emisora { final int? id; final String uuid; final String nombre; final String url; final String? favicon; final String? pais; final String? idioma; final String? tags; final int orden; const Emisora({ this.id, required this.uuid, required this.nombre, required this.url, this.favicon, this.pais, this.idioma, this.tags, this.orden = 0, }); /// Construye una [Emisora] desde una fila de la tabla `favoritos`. factory Emisora.fromMap(Map map) { return Emisora( id: map['id'] as int?, uuid: map['uuid'] as String, nombre: map['nombre'] as String, url: map['url'] as String, favicon: map['favicon'] as String?, pais: map['pais'] as String?, idioma: map['idioma'] as String?, tags: map['tags'] as String?, orden: map['orden'] as int? ?? 0, ); } /// Serializa la emisora para inserción/actualización en SQLite. /// No incluye [id] — lo gestiona la BD. Map toMap() { return { 'uuid': uuid, 'nombre': nombre, 'url': url, 'favicon': favicon, 'pais': pais, 'idioma': idioma, 'tags': tags, 'orden': orden, }; } /// Devuelve una copia con los campos indicados modificados. Emisora copyWith({ int? id, String? uuid, String? nombre, String? url, String? favicon, String? pais, String? idioma, String? tags, int? orden, }) { return Emisora( id: id ?? this.id, uuid: uuid ?? this.uuid, nombre: nombre ?? this.nombre, url: url ?? this.url, favicon: favicon ?? this.favicon, pais: pais ?? this.pais, idioma: idioma ?? this.idioma, tags: tags ?? this.tags, orden: orden ?? this.orden, ); } @override String toString() => 'Emisora(id: $id, uuid: $uuid, nombre: $nombre, orden: $orden)'; @override bool operator ==(Object other) => identical(this, other) || other is Emisora && runtimeType == other.runtimeType && uuid == other.uuid; @override int get hashCode => uuid.hashCode; }