Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:deriv_feature_flag/feature_flag/feature_flag_config.dart';
import 'package:deriv_feature_flag/feature_flag/feature_flag_repository.dart';
import 'package:deriv_feature_flag/growthbook/deriv_growth_book.dart';
import 'package:flutter/material.dart';
import 'package:growthbook_sdk_flutter/growthbook_sdk_flutter.dart';

class DerivFeatureFlag {
/// Initializes the FeatureFlag service for the whole app.
Expand All @@ -17,6 +18,12 @@ class DerivFeatureFlag {
.setup(derivGrowthBook: derivGrowthBook);
}

Map<String, dynamic> features() {
return FeatureFlagRepository.getInstance().features.map((key, value) {
return MapEntry(key, value.defaultValue);
});
}

/// Only for testing purposes.
@visibleForTesting
static Future<void> initializeTest(DerivGrowthBook derivGrowthBook) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ class FeatureFlagRepository {
// Growth Book SDK instance.
late final GrowthBookSDK _growthBookSDK;

Map<String, GBFeature> _features = {};

Map<String, GBFeature> get features => _features;

/// initialize the GrowthBook sdk instance.
Future<void> setup({required DerivGrowthBook derivGrowthBook}) async {
_growthBookSDK = await derivGrowthBook.initializeSDK();
_features = _growthBookSDK.features;
}

/// get the feature flags value from the sdk.
Expand Down
Loading