Skip to content

Kotlin SDK

Kotlinv1.0.0
dependencies {
implementation("gg.flags:flags-kotlin:1.0.0")
}
dependencies {
implementation 'gg.flags:flags-kotlin:1.0.0'
}
<dependency>
<groupId>gg.flags</groupId>
<artifactId>flags-kotlin</artifactId>
<version>1.0.0</version>
</dependency>
import gg.flags.client.FlagsClient
import gg.flags.client.Auth
suspend fun main() {
val client = FlagsClient.builder()
.auth(Auth(
projectId = "your-project-id",
agentId = "your-agent-id",
environmentId = "your-environment-id"
))
.build()
// Check a flag
if (client.isEnabled("new-feature")) {
println("Feature is enabled!")
}
// List all flags
val flags = client.getAllFlags()
flags.forEach { flag ->
println("${flag.details.name}: ${flag.enabled}")
}
client.close()
}

An alternative API style is also available:

import gg.flags.client.*
val client = FlagsClient.NewClient(
WithAuth(Auth(
projectId = "your-project-id",
agentId = "your-agent-id",
environmentId = "your-environment-id"
)),
WithMemory(),
)
if (client.Is("new-feature").Enabled()) {
println("Feature is enabled!")
}
client.close()