feature_flags
this package simply allows you to activate dynamically functionnalities of your app.
usage
setup
wrap your app’s widget in a features
widget.
features(
child: materialapp(
/// ...
),
);
testing if a feature is enabled
to test is a feature is currently enabled, use the features.isfeatureenabled
function with a unique functionnality identifier.
if (features.isfeatureenabled(context, 'decrement')) {
/// the 'decrement' feature is enabled
}
enable or disable a feature
from the features
widget
by updating the flags
from the features
widget.
features(
flags: [ 'decrement' ],
child: materialapp(
/// ...
),
);
enabling it locally from code
you can activate a feature by calling the features.setfeature
function. the feature flag is saved into shared preferences and is persisted between sessions.
features.setfeature(
context,
'decrement',
true,
);
using the debug view
the debug view allow your users to activate or deactivate any dynamic feature.
this may be useful during developpment, but it should be used carefuly.
debugfeatures.show(
context,
availablefeatures: [
feature('decrement', name: 'decrement'),
feature('reset', name: 'reset'),
],
);
Comments are closed.