Creating a Feature Provider
In this codelab, we'll be creating a Feature Provider that fetches JSON asset. But the feature provider that can be created is not limited to JSON file or asset, since Clean Framework follows Open Feature Standard, the feature flagging is vendor-independent. Thus, these provider can be created for any vendor that follows Open Feature Standard.
AssetFeatureProvider
- Create a file named
asset_feature_provider.dart
. - Add the following content to the file.
class AssetFeatureProvider extends JsonFeatureProvider {
Future<void> load(String key) async {
final rawFlags = await rootBundle.loadString(key);
feed(jsonDecode(rawFlags));
}
}
Note: JsonFeatureProvider
is a helper class provider by Clean Framework to help with parsing
JSON flag schema. For vendors that doesn't use JSON, FeatureProvider
class can be used.