feature_flutter

Important note: We recommend that you read about the feature_core package before using it.

Usage

With the feature_flutter package you can integrate features into the Flutter application.

The package provides three main widgets: FeaturesProvider, FeatureWidget, DebugFeaturesWidget.

FeaturesProvider

Passes the manager down the tree.

void main() {
  final FeaturesManager featuresManager = FeaturesManager(...);

  runApp(MaterialApp(
    home: FeaturesProvider(
      manager: featuresManager,
    ),
    ...
  ));
}

FeatureWidget

Allows you to show/hide widgets depending on the value of a feature.

You can use a simplified variant

FeatureWidget(
  feature: featuresManager.getFeature('feature_key'),
  child: Text(
    'child when feature: has 'false' value,'
    'OR is disabled OR not found in manager',
  ),
  activatedChild: Text(
    'child when feature found in manager AND is enabled.'
  ),
  visible: true, // default, totally shows/hides widget
)

Or you can handle feature values more flexibly through the builder.

Important note: By default, if the bilder returns nothing, an empty SizedBox is used.

FeatureWidget.builder(
  feature: featuresManager.getFeatureByType<SomeFeature>(),
  builder: (BuildContext context, Feature? feature) {
    if (feature == null) {
      return // your widget here
    }
    if (feature.enabled) {
      return // your widget here
    }
  },
)

DebugFeaturesWidget

Just a handy widget which depends on the manager and gives access to enable/disable features.

Libraries

feature_flutter