feat(mvp): PluriWave Fase 1 — estructura completa de la app #3

Merged
FreeTLab merged 4 commits from feature/mvp-fase1 into main 2026-04-04 18:52:59 +02:00
Showing only changes of commit a3444d7c49 - Show all commits

97
lib/modelos/emisora.dart Normal file
View File

@@ -0,0 +1,97 @@
/// 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<String, dynamic> 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<String, dynamic> 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;
}