feature_flags_toggly

Last updated:

0 purchases

feature_flags_toggly Image
feature_flags_toggly Images
Add to Cart

Description:

feature flags toggly

Dart package that provides feature flags support for flutter applications allowing you to enable and disable features easily.
Can be used WITH or WITHOUT Toggly.io.
What is a Feature Flag #
A feature flag (or toggle) in software development provides an alternative to maintaining multiple feature branches in source code. A condition within the code enables or disables a feature during runtime.
In agile settings the feature flag is used in production, to switch on the feature on demand, for some or all the users. Thus, feature flags make it easier to release often. Advanced roll out strategies such as canary roll out and A/B testing are easier to handle.
Installation #
$ flutter pub add feature_flags_toggly
copied to clipboard
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):
dependencies:
feature_flags_toggly: ^0.0.1
copied to clipboard
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:feature_flags_toggly/feature_flags_toggly.dart';
copied to clipboard
Basic Usage (with Toggly.io) #
Initialize Toggly by running the Toggly.init method and by providing your App Key from your Toggly application page
@override
void initState() {
initToggly();
super.initState();
}

void initToggly() async {
await Toggly.init(
appKey: '<your_app_key>',
environment: '<your_app_environment>',
flagDefaults: {
"ExampleFeatureKey1": true,
"ExampleFeatureKey2": false,
"ExampleFeatureKey3": true,
},
);
}
copied to clipboard
Now simply wrap your widgets in Feature widgets and provide them with the featureKeys that best describe them.
Feature(
featureKeys: const ['ExampleFeatureKey1'],
child: const Text('This text will show if ExampleFeatureKey1 is FALSE'),
),
copied to clipboard
You can also use multiple feature keys for one Feature widget and make use of the requirement (FeatureRequirement.all, FeatureRequirement.any) and negate (bool) options.
Feature(
featureKeys: const ['ExampleFeatureKey1', 'ExampleFeatureKey2'],
requirement: FeatureRequirement.any,
child: const Text('This text will show if ANY of the provided feature keys are TRUE'),
),
copied to clipboard
Feature(
featureKeys: const ['ExampleFeatureKey1', 'ExampleFeatureKey2'],
requirement: FeatureRequirement.all,
child: const Text('This text will show if ALL the provided feature keys are TRUE'),
),
copied to clipboard
Feature(
featureKeys: const ['ExampleFeatureKey1'],
negate: true,
child: const Text('This text will show if ExampleFeatureKey1 is FALSE'),
),
copied to clipboard
Lastly, you can also evaluate the value of a Feature gate by calling evaluateFeatureGate directly, using the same arguments as for the Feature widget.
await Toggly.evaluateFeatureGate(
["ExampleFeatureKey1", "ExampleFeatureKey2"],
requirement: FeatureRequirement.all,
negate: true,
);
copied to clipboard
Basic Usage (without Toggly.io) #
Initialize Toggly by running the Toggly.init method
@override
void initState() {
initToggly();
super.initState();
}

void initToggly() async {
await Toggly.init(
flagDefaults: {
"ExampleFeatureKey1": true,
"ExampleFeatureKey2": false,
"ExampleFeatureKey3": true,
},
);
}
copied to clipboard
Now simply wrap your widgets in Feature widgets and provide them with the featureKeys that best describe them.
Feature(
featureKeys: const ['ExampleFeatureKey1'],
child: const Text('This text will show if ExampleFeatureKey1 is FALSE'),
),
copied to clipboard
You can also use multiple feature keys for one Feature widget and make use of the requirement (FeatureRequirement.all, FeatureRequirement.any) and negate (bool) options.
Feature(
featureKeys: const ['ExampleFeatureKey1', 'ExampleFeatureKey2'],
requirement: FeatureRequirement.any,
child: const Text('This text will show if ANY of the provided feature keys are TRUE'),
),
copied to clipboard
Feature(
featureKeys: const ['ExampleFeatureKey1', 'ExampleFeatureKey2'],
requirement: FeatureRequirement.all,
child: const Text('This text will show if ALL the provided feature keys are TRUE'),
),
copied to clipboard
Feature(
featureKeys: const ['ExampleFeatureKey1'],
negate: true,
child: const Text('This text will show if ExampleFeatureKey1 is FALSE'),
),
copied to clipboard
Lastly, you can also evaluate the value of a Feature gate by calling evaluateFeatureGate directly, using the same arguments as for the Feature widget.
await Toggly.evaluateFeatureGate(
["ExampleFeatureKey1", "ExampleFeatureKey2"],
requirement: FeatureRequirement.all,
negate: true,
);
copied to clipboard
Find out more about Toggly.io #
Visit our official website or check out a video overview of our product.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.