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()
}
}

See also

Constructors

Link copied to clipboard
constructor(name: String, description: String?, isEnabled: Boolean)

Properties

Link copied to clipboard
open override val description: String?

Optional human-readable description explaining what this feature does.

Link copied to clipboard
open override val isEnabled: Boolean

Whether the feature is currently enabled on this device.

Link copied to clipboard
open override val name: String

The unique identifier name of the feature (e.g., "dark_mode").