⚙️ Core¶
GraphQL Client¶
final client = GraphQLClientService.getClient();
// Query
final result = await client.query(QueryOptions(
document: gql(myQuery),
variables: {'id': '123'},
));
// Token management
await GraphQLClientService.saveToken(token);
await GraphQLClientService.clearToken();
final hasSession = await GraphQLClientService.hasActiveSession();
Network¶
Circuit Breaker¶
Implementa el patrón REQ-REL-002: Circuit Breaker ante fallas. Protege contra fallos en cascada.
// Configuración (default)
final breaker = CircuitBreaker(
failureThreshold: 7, // fallos antes de abrir
successThreshold: 2, // éxitos para cerrar
timeout: Duration(seconds: 30),
);
Estados:
- closed - Normal, permite peticiones
- open - Bloquea todas las peticiones
- half-open - Permite pruebas para recuperar
Uso:
final manager = CircuitBreakerManager(); // usa defaults
// Antes de cada petición
if (!manager.isAvailable('/api/users')) {
throw Exception('Servicio no disponible');
}
// Después de cada respuesta
manager.recordSuccess('/api/users');
manager.recordFailure('/api/users');
Interceptors¶
AuthInterceptor- JWT headersErrorInterceptor- Error handlingLoggingInterceptor- Request/response loggingRetryInterceptor- Auto retry
Network Info¶
Storage¶
Secure Storage (tokens)¶
Profile Cache¶
await ProfileCacheStore.cacheProfile(user);
final cached = await ProfileCacheStore.getCachedProfile();
Payments (LATAM)¶
Gateways: OnvoPay, Tilopay (CR), Wompi (CO), Conekta (MX), MercadoPago (BR)
final gateway = PaymentGatewayFactory.create(
type: PaymentGatewayType.onvoPay,
config: PaymentGatewayConfiguration(publicKey: 'pk_...'),
);
final token = await gateway.tokenizeCard(...);
final result = await gateway.processPayment(amount: 50000, currency: Currency.crc);
Widgets (Atomic Design)¶
Atoms¶
AppCircularButtonAppRoleBadgeSyncStatusIndicator
Molecules¶
AppInputCardAppNavItemAppServiceCardHomeWelcomeHeaderProfileMenuOption
Organisms¶
MainNavigationBarProfileHeaderStickyActionFooterSecureCardInputWidget
Services¶
AuthService- SesionesGeolocationService- GPSLoggingService- Logs