-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
This page walks through the minimum steps to install Featured, declare one flag, and read its value. The whole thing fits in about 15 minutes.
| Platform | Status | Notes |
|---|---|---|
| Android | Stable | Public API is covered by SemVer. Breaking changes only in major releases. |
| iOS (SKIE/DCE) | Preview | Public API may change in minor releases without a major version bump. |
| JVM / Compose Desktop | Preview | Public API may change in minor releases without a major version bump. |
Add the repositories to settings.gradle.kts:
dependencyResolutionManagement {
repositories {
mavenCentral()
google()
}
}Apply the Gradle plugin and declare dependencies in your app (or shared) module:
// build.gradle.kts
plugins {
id("dev.androidbroadcast.featured") version "<version>"
}
dependencies {
implementation(platform("dev.androidbroadcast.featured:featured-bom:<version>"))
// Core runtime — always required
implementation("dev.androidbroadcast.featured:featured-core")
// Local persistence — DataStore is the recommended choice for Android
implementation("dev.androidbroadcast.featured:featured-datastore-provider")
}The latest version is available on Maven Central.
Add a featured { } block to the same build.gradle.kts:
featured {
localFlags {
boolean("new_checkout", default = false) {
description = "Enable the new checkout flow"
category = "Checkout"
}
}
}After syncing, the Gradle plugin generates:
-
internal object GeneratedLocalFlagswith aConfigParam<Boolean>property fornew_checkout - A public extension function
fun ConfigValues.isNewCheckoutEnabled(): Boolean
No further code is needed to declare the flag.
Create a ConfigValues instance once at app startup (e.g., in Application.onCreate or your DI graph):
import androidx.datastore.preferences.core.PreferenceDataStoreFactory
import dev.androidbroadcast.featured.ConfigValues
import dev.androidbroadcast.featured.datastore.DataStoreConfigValueProvider
val dataStore = PreferenceDataStoreFactory.create { context.dataStoreFile("feature_flags.preferences_pb") }
val configValues = ConfigValues(
localProvider = DataStoreConfigValueProvider(dataStore),
)One-shot read in a coroutine:
val isEnabled: Boolean = configValues.isNewCheckoutEnabled()Reactive read in a ViewModel:
val isNewCheckoutEnabled: StateFlow<Boolean> =
configValues.observe(GeneratedLocalFlags.newCheckout)
.map { it.value }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), false)The flag you just created is already eligible for dead-code elimination — see Release Optimization. With default = false, R8 will strip every code path behind isNewCheckoutEnabled() from your release APK without any additional configuration.
For the full artifact list (iOS, JVM, optional modules) see Installation.