Feature flags for Flutter — remote toggles for iOS, Android, and web apps
Sign up at flagbit.anethoth.com to get your SDK key. The free tier includes 1,000 evaluations/day.
flutter pub add http
import 'dart:convert';
import 'package:http/http.dart' as http;
class FlagBit {
static const String _url = 'https://flagbit.anethoth.com/api/v1/evaluate';
static String sdkKey = const String.fromEnvironment('FLAGBIT_SDK_KEY');
static final Map<String, bool> _cache = {};
static Future<bool> isEnabled(String flagKey, {Map<String, String>? context}) async {
final cacheKey = '\$flagKey:\${context.hashCode}';
if (_cache.containsKey(cacheKey)) return _cache[cacheKey]!;
try {
final resp = await http.post(
Uri.parse(_url),
headers: {'Content-Type': 'application/json', 'X-SDK-Key': sdkKey},
body: jsonEncode({'flag_key': flagKey, 'context': context ?? {}}),
);
final value = jsonDecode(resp.body)['value'] as bool;
_cache[cacheKey] = value;
return value;
} catch (_) {
return false;
}
}
}
// Widget usage
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FutureBuilder<bool>(
future: FlagBit.isEnabled('new-home-layout', context: {'user_id': userId}),
builder: (ctx, snapshot) {
if (snapshot.data == true) {
return NewHomeLayout();
}
return ClassicHomeLayout();
},
);
}
}
// Provider pattern for app-wide flags
class FeatureFlagProvider extends ChangeNotifier {
final Map<String, bool> _flags = {};
Future<void> loadFlags(List<String> keys) async {
for (final key in keys) {
_flags[key] = await FlagBit.isEnabled(key);
}
notifyListeners();
}
bool isEnabled(String key) => _flags[key] ?? false;
}
A/B test different layouts, color schemes, or navigation patterns on mobile devices.
Enable features only on iOS or Android using platform context in targeting rules.
Roll out new features to 5% of mobile users, then increase based on crash rates and feedback.
Instantly disable a buggy feature on all mobile devices without pushing an app update.
Define flags in your FlagBit dashboard with targeting rules and rollout percentages.
Call the evaluate endpoint from your Flutter app with user context for targeted rollouts.
Enable, disable, or adjust rollouts in real-time. No redeployment needed.
Cache flag values locally (SharedPreferences) for offline fallback. Refresh when connectivity returns.
Use FutureBuilder or load all flags at app startup via the Provider pattern shown above.
Yes — pass {'platform': 'ios'} or {'platform': 'android'} in the context for platform-specific targeting.
FlagBit works identically in Flutter web — it's just an HTTP call.
Free tier includes 1 project, 10 flags, and 1,000 evaluations/day. No credit card required.
Get Your Free API Key