Introduction

One of the most useful tools in the modern developer's toolbox is the feature flag. Feature flag enable you to deploy new features into a production environment, but restrict their availability. These are great for better control and experimentation of features.

What are feature flags ?

Feature flags are built upon conditional logic that control visibility of functionality for users at run time.

Feature flagging allows companies to quickly deliver and deploy software to their users. With the flick of a switch, you can activate a new feature for specific users without restarting the app or deploying new code, enable gradual feature rollouts, fix bugs more easily, and provide a more streamlined development cycle. Feature flagging is also useful for rolling back the code if needed.

Merits of feature flags

Feature flags have become an absolute necessity when releasing new features rapidly and safely. Here are some of the ways that they bring value to your software:

  • Continuous Experimentation: Conduct experimental feature releases to small user segments to validate feasibility and popularity.
  • Risk Mitigation: Stabilize a system by quickly deactivating a problem feature, avoiding the risks of a rollback or immediate hotfix.
  • Panic Resolution: Disable an optional feature with high resource consumption during peak usage periods.
  • Increase Engineering Velocity: Feature flags allow you to continuously test in production without risks. This way, you can release your features much faster to your users and since you’re continuously validating your changes on a subset of users, you end up with higher-quality and less buggy releases.

Challenges with feature flags

With time and as use-cases evolve, using feature flags can become complex, especially as some organizations opt for an in-house system which can lack the level of sophistication necessary to support your products.

Also, the build up of feature flags in your system can lead to messy code over time. These conditional statements scattered in your code base can disrupt the flow of your system and multiple code paths make it hard to determine the cause of an issue when it comes time to debug.

OpenFeature Standard

Thankfully, OpenFeature Standard tries to solve these challenges by providing an open standard for Feature Flag management. You can read more about the OpenFeature Standard at:

What you'll build

In this codelab, you'll build an app that makes use of Feature Flagging with the help of Clean Framework provided APIs based on Open Feature Standard. It will contain:

  • A login page that accepts an email
  • A counter page that styles itself based on feature flags; evaluated with email context
  • The counter decides the incrementing factor based on feature flags
..
Login Page
Counter page

What you'll learn

In this codelab, you'll learn to use the Feature Flagging APIs included in Clean Framework, in two different ways, viz. using FeatureBuilder and using OpenFeatureClient methods directly, including:

  • How to create your own FeatureProvider to fetch flag configuration from a JSON file
  • How to use FeatureScope to register the feature provider
  • How to use EvaluationContext to evaluate feature flags based on some state/context
  • How to use FeatureBuilder to resolve flags in UI
  • How to use OpenFeatureClient methods to resolve flags in non-UI code

What you'll need

  • Basic knowledge of Flutter development and Dart
  • Basic understanding of Feature Flag (read through the links provided above, in case you have missed them)
  • A code editor
  • The sample code (see next step)