LocalFeature
data class LocalFeature(val name: String, val description: String?, val isEnabled: Boolean) : Feature
A locally-managed feature flag stored on the device.
Local features are simple boolean flags that are stored and managed entirely on the device using DataStore. They are ideal for features that should be controlled on a per-device or per-user basis without remote configuration.
Unlike RemoteFeature, local features have a straightforward on/off state without the concept of remote values or local overrides.
Use Cases
User preferences (e.g., dark mode, notifications)
Device-specific settings
Features in development that aren't ready for remote control
A/B test variants assigned to specific devices
Usage Example
val darkMode = Feature.LocalFeature(
name = "dark_mode",
description = "Enable dark theme throughout the app",
isEnabled = false
)
// Check if enabled
@Composable
fun App() {
val featureHandler = LocalFeatureHandler.current
val isDarkModeEnabled by featureHandler.isFeatureEnabled("dark_mode")
MaterialTheme(
colorScheme = if (isDarkModeEnabled) darkColorScheme() else lightColorScheme()
) {
Content()
}
}Content copied to clipboard