firebase_feature_flag

Last updated:

0 purchases

firebase_feature_flag Image
firebase_feature_flag Images
Add to Cart

Description:

firebase feature flag

firebase_feature_flag #
A Flutter package for managing feature flags using Firebase Realtime Database.
Table of Contents #

firebase_feature_flag
Table of Contents

Overview
Key Features

Realtime Synchronous
Cache
Performance
Efficient Instance Management
Flexible Configuration Options
Widget Lifecycle Control


Installation
Usage

1. Initialize a FeatureFlag instance
2. Use FeatureFlagBuilder to conditionally display UI
3. Get the current value from anywhere
4. Configure the Real Time Database
5. Disable log


Example
Contributing



Overview #
firebase_feature_flag provides a convenient way to integrate feature flags into your Flutter app, allowing you to toggle features on and off remotely without requiring a new release. It utilizes Firebase Realtime Database to store and synchronize feature flag configurations in realtime.
Key Features #
Realtime Synchronous #

Realtime Synchronous: Enjoy real-time synchronization of feature flag changes across your Flutter app.

Changes in the Firebase Realtime Database are reflected synchronously, providing immediate updates to feature flags.



Cache #

Cache: Enhance performance and reduce latency by utilizing the cache for storing feature flag configurations.

Cached configurations provide quick access to feature flags, especially in scenarios with limited or no internet connectivity.



Performance #

Enhanced Performance: Experience optimized performance with a unified remote listener for all features.

All FeatureFlag instances efficiently listen to a single stream subscription from the Firebase Realtime Database.
Stream subscriptions are automatically disposed of after all features are released, ensuring optimal performance.



Efficient Instance Management #

Instance Management: Improved instance management ensures a streamlined experience.

FeatureFlag instances are thoughtfully managed to guarantee a single instance for each feature key.



Flexible Configuration Options #

Configuration Flexibility: Tailor feature flag behavior with new configuration options.

Utilize the useCache property in FeatureFlag to decide whether to use the cache.
Leverage the dispose method in FeatureFlag for efficient stream subscription closure.



Widget Lifecycle Control #

Widget Management: Gain control over widget lifecycles with added properties in FeatureFlagBuilder.

Use the dispose property to determine whether to dispose or keep the feature after the widget is disposed (default is false).



Installation #
Add firebase_feature_flag to your pubspec.yaml file:
dependencies:
firebase_feature_flag: ^1.0.14
copied to clipboard
Run flutter pub get to install the package.
Usage #
1. Initialize a FeatureFlag instance #
import 'package:firebase_feature_flag/firebase_feature_flag.dart';

final FeatureFlag<bool> myFeatureFlag = FeatureFlag<bool>(
key: 'my_feature',
initialValue: true,
);
copied to clipboard
2. Use FeatureFlagBuilder to conditionally display UI #
FeatureFlagBuilder<bool>(
feature: myFeatureFlag,
builder: (context, isEnabled) {
return isEnabled
? CustomWidget(message: 'Custom Widget is Enabled!')
: Text('Custom Widget is Disabled.');
},
),
copied to clipboard
3. Get the current value from anywhere #

// Get the feature value
final bool isMyfeatureEnabled = myFeatureFlag.value;
if(isMyfeatureEnabled){
// Do somthing
}else{
// Do something
}

// Or listen to the feature value
// The stream subscription will automatically canceled after disposing the feature.
myFeatureFlag.listen((value){
print(value);
});
copied to clipboard
4. Configure the Real Time Database #
Below is an example of how you can structure your Firebase Realtime Database to incorporate feature flags.
{
// `feature` is the default path, you can change it when define the FeatureFlag
"features": {
"bool_feature": false,
"bool_feature_platform_specific": {
"android": true,
"ios": false
},
"int_feature": 34,
"string_feature": "active",
// Add more feature flags as needed
}
}
copied to clipboard
In this example:

"bool_feature" has a boolean value.
"bool_feature_platform_specific" has a platform-specific boolean value.
"int_feature" has an int value.
"string_feature" has a string value.

5. Disable log #
The log is only enabled in the debug mode but you can disbale it by setting the FeatureFlag.showLogs to false.
FeatureFlag.showLogs = false;
copied to clipboard
Example #
Check the provided example in the example directory for a sample implementation.
Contributing #
Feel free to open issues and pull requests. Contributions are welcome!

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.