Feature Flags
Evaluate feature flags locally with the Flutter SDK. The SDK fetches your flag config with a public key, caches it, and evaluates every check in-process — no network call per isEnabled().
Setup
import 'package:simplr_fraud/simplr_fraud.dart';
final flags = SimplrFlags();
await flags.initialize(
apiKey: 'pk_live_xxx', // public key only (pk_*)
environment: 'live', // 'live' | 'test' (default 'test')
refreshInterval: const Duration(minutes: 1), // 0 disables auto-refresh
);
initialize() fetches the config once and starts a background refresh. Call it once at app startup and keep the instance around.
Identifying the user
flags.setUser('user_123');
If you don't set a user, the SDK falls back to the device ID for bucketing, so anonymous users still get stable results.
Checking a flag
if (flags.isEnabled('new-checkout')) {
// ...
}
// Per-call context for rules or a one-off user:
flags.isEnabled(
'new-checkout',
userId: 'user_123',
attributes: {'plan': 'growth', 'country': 'GB'},
);
isEnabled() returns synchronously and is free — it never hits the network.
API
| Method | Description |
|---|---|
initialize({apiKey, environment, baseUrl, refreshInterval}) | Fetch config and start auto-refresh. Returns a Future. |
setUser(userId) | Set the default identifier used for bucketing. |
isEnabled(key, {userId, attributes}) | Evaluate a flag locally. |
refresh() | Manually re-fetch the config (counts as one billable request). |
getAll() | Return the current cached flag map. |
dispose() | Stop the auto-refresh timer. |
Billing note
Each initialize() and refresh() counts as one flag config request. Local isEnabled() calls are never billed. The first 1,000,000 requests per month are free — see Pricing.