/// Modelo de usuario para el pool de usuarios en modo multi-dispositivo class Usuario { final String id; final String nombre; final String? avatar; final String? creadoPorClienteId; final String? clienteIdSeleccionado; Usuario({ required this.id, required this.nombre, this.avatar, this.creadoPorClienteId, this.clienteIdSeleccionado, }); bool get estaSeleccionado => clienteIdSeleccionado != null; bool get estaDisponible => clienteIdSeleccionado == null; Usuario copiar({ String? id, String? nombre, String? avatar, String? creadoPorClienteId, String? clienteIdSeleccionado, bool liberarSeleccion = false, }) { return Usuario( id: id ?? this.id, nombre: nombre ?? this.nombre, avatar: avatar ?? this.avatar, creadoPorClienteId: creadoPorClienteId ?? this.creadoPorClienteId, clienteIdSeleccionado: liberarSeleccion ? null : (clienteIdSeleccionado ?? this.clienteIdSeleccionado), ); } Map toJson() => { 'id': id, 'nombre': nombre, if (avatar != null) 'avatar': avatar, if (creadoPorClienteId != null) 'creadoPorClienteId': creadoPorClienteId, if (clienteIdSeleccionado != null) 'clienteIdSeleccionado': clienteIdSeleccionado, }; factory Usuario.fromJson(Map json) => Usuario( id: json['id'] as String, nombre: json['nombre'] as String, avatar: json['avatar'] as String?, creadoPorClienteId: json['creadoPorClienteId'] as String?, clienteIdSeleccionado: json['clienteIdSeleccionado'] as String?, ); }