A lightweight client for consuming Flipt feature flag snapshots in Flutter/Dart applications. The SDK provides typed accessors, offline fallback, and optional persistent caching so you can toggle experiences without shipping a new build.
It's really hard to set value other then bool when using Flipt. So, I create this package that uses description as value of the flag. Because of that, it will not have the full features when comparing to the original package.
- Typed helpers for
bool,int,double,String,List, andMapflag values - Optional persistent caching via
SharedPreferences - Periodic background refresh with configurable interval and timeout
- Entity and context support for server-side evaluations
- Works offline by falling back to cached data or local defaults
-
Add the dependency to your Flutter project:
flutter pub add flipt
-
Ensure you have a Flipt API token and know the namespace/environment you want to target.
Create a single Flipt instance and keep it alive for as long as you need to evaluate flags.
import 'package:flipt/flipt.dart';
Future<void> bootstrapFeatureFlags() async {
final flipt = Flipt(
host: 'feature-flags.example.com',
token: 'your-api-token',
namespace: 'production',
environment: 'mobile-app',
entityId: 'user-42',
context: const {
'app_version': '2.5.0',
'platform': 'ios',
},
defaultValues: {
'new_checkout_flow': false,
'max_recommendations': 6,
'api_base_url': 'https://api.example.com',
'checkout_thresholds': const <String, Object>{
'caution': 0.6,
'critical': 0.9,
},
'supported_locales': const <String>['en', 'vi'],
},
storage: FliptSharedPreferencesStorage('Flipt'), // See more in example
fetchInterval: const Duration(minutes: 15),
timeout: const Duration(seconds: 5),
shouldFetchFromRemote: () async {
final connected = await Connectivity().checkConnectivity();
return !connected.contains(ConnectivityResult.none);
},
isDebug: true,
);
await flipt.ensureInitialized;
final newFlowEnabled =
flipt.getBool('new_checkout_flow', defaultValue: false);
final maxRecommendations =
flipt.getInt('max_recommendations', defaultValue: 3);
final checkoutThresholds = flipt.getMap<double>('checkout_thresholds');
final supportedLocales = flipt.getList<String>('supported_locales');
// Use the values in your UI/business logic...
flipt.dispose();
}See example for a more complete sample.
This package ships with unit tests that cover the typed value helpers. You can run them locally with:
flutter test- Please remember that the package uses
descriptionact as value of the flag so it will not have the full features as the original one. - Issues & feature requests: GitHub Issues
- Follow the official Flipt documentation for advanced configuration:
https://www.flipt.io/docs