SDK de Dart
El cliente para aplicaciones Flutter y Dart: Dart puro, sin dependencias en tiempo de ejecución, y con los mismos eventos, banderas y bandeja de entrada que los demás clientes.
Dónde se publica
prodantix_sdk on pub.dev. Pure Dart, with no runtime dependencies.
Instalación
Bash
dart pub add prodantix_sdkEjemplo
Dart
import 'package:prodantix_sdk/prodantix_sdk.dart';
const projectKey = String.fromEnvironment('PRODANTIX_PUBLIC_KEY');
final client = ProdantixClient(
apiKey: projectKey,
host: 'https://eu.api.prodantix.com',
);
client.identify('user-123');
client.capture('order.completed', properties: {'total': 42});
final inbox = await client.getInbox();
await client.shutdown();Este cliente recuerda quién lo está usando, así que identify fija el id una sola vez y cada llamada posterior trata de esa persona. Llama a reset al cerrar sesión.
Banderas remotas y locales
Una comprobación remota pregunta al servidor y es la autoritativa. Una comprobación local evalúa en el proceso una instantánea en caché del conjunto de reglas, sin ida y vuelta por llamada, que es lo que pide una ruta caliente.
Dart
// Remote: asks the server, and is the authoritative answer.
if (await client.isFeatureEnabled('new-checkout')) {
// ...
}
// Local: evaluated in process from a cached snapshot, no round trip per call.
if (await client.isFeatureEnabledLocal('new-checkout', properties: {'plan': 'pro'})) {
// ...
}
// Every per-flag read records one $feature_flag_called exposure.
final variant = await client.getVariant('new-checkout');
if (variant?['key'] == 'treatment') {
// ...
}
// A flag targeting a cohort reads this user's memberships from the store;
// pass them yourself to skip the lookup.
if (await client.isFeatureEnabledLocal('members', cohorts: ['<cohort id>'])) {
// ...
}Dónde se ejecuta
Apunta a móvil y a la máquina virtual de Dart, y llega a la red a través de dart:io. En cualquier otra plataforma, pásale tu propio Transport y Requester; nada más del cliente cambia.
Dart
final client = ProdantixClient(
apiKey: projectKey,
host: 'https://eu.api.prodantix.com',
transport: MyTransport(),
requester: myRequester,
// Hold a Socket.IO subscription to flag changes and refetch the snapshot on
// push, instead of waiting for the 30s poll.
streamFlags: true,
);