M
María García
Soluciones Ibéricas · LinkedIn
4.800 €
calificado
J
Javier Torres
DigitalPro SL · Google Ads
12.000 €
contactado
A
Ana Rodríguez
Ecom Ventures · Referido
8.500 €
nuevo
P
Pedro Mas
Fintech Iberia · Cold Email
22.000 €
cerrado
L
Laura Vidal
StartupBCN · Instagram
3.200 €
perdido
+
Endpoints implementados
DART| Verbo | Ruta | Método Dart | Status OK | Isolate |
|---|---|---|---|---|
| GET | /leads | fetchLeads() | 200 | ✓ compute() |
| GET | /leads/{id} | fetchLead(id) | 200 | — inline |
| POST | /leads | createLead(lead) | 201 | — inline |
| PUT | /leads/{id} | updateLead(lead) | 200 | — inline |
| DEL | /leads/{id} | deleteLead(id) | 200/204 | — void |
Modelo Lead — fromJson / toJson
class Lead {
final int id;
final String nombre, empresa, email;
final String estado, fuente, asignadoA;
final double valorEstimado;
final DateTime fechaCreacion;
factory Lead.fromJson(Map<String, dynamic> json) => Lead(
id: json['id'] as int,
nombre: json['nombre'] as String,
estado: json['estado'] as String,
valorEstimado: (json['valor_estimado'] as num).toDouble(),
fechaCreacion: DateTime.parse(json['fecha_creacion']),
// ... otros campos
);
}
// Parseo en background → sin jank en listas grandes
List<Lead> _parseLeads(String body) =>
(jsonDecode(body) as List)
.cast<Map<String, dynamic>>()
.map(Lead.fromJson).toList();
Future<List<Lead>> fetchLeads() async {
final res = await _client.get(
Uri.parse('$_baseUrl/leads'),
headers: _headers,
);
if (res.statusCode == 200)
return compute(_parseLeads, res.body);
throw LeadApiException(res.statusCode, res.body);
}
Flujo de datos — FutureBuilder
📱
LeadsScreen
StatefulWidget
→
⚙️
LeadService
fetchLeads()
→
🌐
http.get()
Bearer token
→
🔄
compute()
Isolate background
→
📦
List<Lead>
fromJson tipado
→
🏗️
FutureBuilder
data/error/loading
→
📋
ListView
LeadCard UI