You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 libraryclassFlagsmithService {
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;
Futureinitialise() 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');
}
boolget isSSOEnabled =>true; //_isSSOEnabled;boolget isThirdPartyEnabled => _isThirdPartyEnabled;
boolget isGoogleAuthEnabled => _isGoogleAuthEnabled;
boolget isFacebookAuthEnabled => _isFacebookAuthEnabled;
boolget 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 text was updated successfully, but these errors were encountered:
@FilledStacks Hi, thanks for your example.
You should use seeds for default values of your flags. BT will use values from seed before you update from api.
extensionFlagXonFlag {
staticintgenerateNum(int min, int max) => min +Random().nextInt(max - min);
staticFlagseed(String featureName, {bool enabled =true, String value}) {
var id =generateNum(1, 100);
returnFlag.named(
id: id,
stateValue: value,
feature:Feature.named(
id: id,
name: featureName,
createdDate:DateTime.now().add(Duration(days:generateNum(0, 10))),
type:FlagType.flag),
enabled: enabled);
}
}
// prepare default values before you update new values from apifinal seeds = [
FlagX.seed('third-party', true),
];
final bulletTrain =BulletTrainClient(
apiKey: apiKey,
seeds: seeds,
config:BulletTrainConfig(storeType:StoreType.persistant));
await bulletTrain.getFeatureFlags(); // will trigger update from flagsmith apibool isThirdParty = bulletTrain.hasFeatureFlag('third-party');
final thirdPartyValue = bulletTrain.getFeatureFlagValue('third-party');
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 forhasFeatureFlag
. This works perfectly fine on the website implementation. Below is the Service we're using and the logic to fetch the values.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 text was updated successfully, but these errors were encountered: