isEnabled method
Check if a boolean feature flag is enabled.
This method is designed for feature flags that have boolean values. If the flag's value is not a boolean type, the fallback value will be returned.
flagNameThe name of the feature flagfallbackValueA fallback value to use if the flag is not found, not ready, or has a non-boolean value
Returns true if the flag is enabled, the fallback value otherwise.
Implementation
Future<bool> isEnabled(String flagName, bool fallbackValue) async {
if (!_MixpanelHelper.isValidString(flagName)) {
developer.log('`isEnabled` failed: flagName cannot be blank',
name: 'Mixpanel');
return fallbackValue;
}
final result = await _channel.invokeMethod<bool>('isEnabled', <String, dynamic>{
'token': _token,
'flagName': flagName,
'fallbackValue': fallbackValue,
});
return result ?? fallbackValue;
}