printeastwoodcz / bullet_train_flutter Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
We've integrated flagsmith with our Flutter client recently. We've been stuck for two days now with the value returning null for isFeatureFlagEnabled
and false for hasFeatureFlag
. This works perfectly fine on the website implementation. Below is the Service we're using and the logic to fetch the values.
@singleton
/// A wrapper service for the Bullet train library
class FlagsmithService {
final log = getLogger('FlagsmithService');
final _sharedPreferences = locator<SharedPreferencesService>();
final _bulletTrainClient = BulletTrainClient(
apiKey: FlavorConfig.instance.values.bulletTrainEnvironmentApiKey,
config: BulletTrainConfig(
isDebug: true,
),
);
bool _isSSOEnabled = false;
bool _isThirdPartyEnabled = false;
bool _isGoogleAuthEnabled = false;
bool _isFacebookAuthEnabled = false;
bool _isAppleAuthEnabled = false;
Future initialise() async {
_isSSOEnabled = await _getFeatureEnabled('auth');
_isThirdPartyEnabled = await _getFeatureEnabled('third-party');
_isGoogleAuthEnabled = await _getFeatureEnabled('google-login');
_isFacebookAuthEnabled = await _getFeatureEnabled('facebook-login');
_isAppleAuthEnabled = await _getFeatureEnabled('apple-login');
}
bool get isSSOEnabled => true; //_isSSOEnabled;
bool get isThirdPartyEnabled => _isThirdPartyEnabled;
bool get isGoogleAuthEnabled => _isGoogleAuthEnabled;
bool get isFacebookAuthEnabled => _isFacebookAuthEnabled;
bool get isAppleAuthEnabled => _isAppleAuthEnabled;
Future<bool> _getFeatureEnabled(String key) async {
final user = FeatureUser(
identifier: _sharedPreferences.idempotencyKey,
);
var featureEnabledValue =
await _bulletTrainClient.isFeatureFlagEnabled(key, user: user);
var hasFeature = await _bulletTrainClient.hasFeatureFlag(key, user: user);
log.d('hasFeature:$hasFeature key:$key');
return featureEnabledValue ?? false;
}
}
We triple double quadruple checked the api key and it's correct. We have tried a different one. One other thing to note is that it's not printing out any logs or throwing any exceptions. I've set isDebug to true but there's no logs to be found in the Debug Console.
The code below was what we use to use to check if a feature is enabled.
var featureEnabledValue =
await _bulletTrainClient.isFeatureFlagEnabled(key);
What do we use now to replace this. The getFeatureFlagValue
returns a key but we need a bool and don't want any magic / const strings in our app that's depending on user input.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.