Package-level declarations

EnvSource, DotEnvSource, PropertiesSource and the Android initializer.

EnvSource, DotEnvSource, PropertiesSource and the Android initializer.

EnvSource, DotEnvSource, PropertiesSource and the Android initializer.

EnvSource, DotEnvSource, PropertiesSource and the Android initializer.

EnvSource, DotEnvSource, PropertiesSource and the Android initializer.

EnvSource, DotEnvSource, PropertiesSource and the Android initializer.

EnvSource, DotEnvSource, PropertiesSource and the Android initializer.

EnvSource, DotEnvSource, PropertiesSource and the Android initializer.

Types

Link copied to clipboard

Reads a .env file of KEY=value lines, with keys in SCREAMING_SNAKE_CASE. Unlike the other file sources, keys are matched exactly, including case.

Link copied to clipboard

Reads environment variables, with keys in SCREAMING_SNAKE_CASE (DATABASE_URL). Names are matched exactly, including case. Variables are read at each lookup, not copied up front. On JS and Wasm it reads process.env under Node; browsers have no environment, so every lookup there returns null.

Link copied to clipboard

Captures the application context at startup so bundled assets can be read without a Context. Not registered by default, so apps that don't read assets get no extra provider. To use it, declare it in your app's manifest:

Link copied to clipboard
class PropertiesSource(properties: Map<String, String>, origin: String? = null) : MapBackedSource

Reads .properties files. Keys use dot.notation, with SCREAMING_SNAKE_CASE as a fallback; a key with no exact match falls back to a case-insensitive one.

Functions

Link copied to clipboard

Gives Konstant the application context for reading assets. Needed only for fromResource sources: call it in Application.onCreate before loading, or register KonstantInitProvider in your manifest to do it at app start.

Link copied to clipboard
actual fun readFileText(path: String): String

Reads the text file at path. Throws if it cannot be read; in browsers, which have no file system, it always throws. Used by the sources' fromFile functions.

expect fun readFileText(path: String): String

Reads the text file at path. Throws if it cannot be read; in browsers, which have no file system, it always throws. Used by the sources' fromFile functions.

actual fun readFileText(path: String): String

Reads the text file at path. Throws if it cannot be read; in browsers, which have no file system, it always throws. Used by the sources' fromFile functions.

actual fun readFileText(path: String): String

Reads the text file at path. Throws if it cannot be read; in browsers, which have no file system, it always throws. Used by the sources' fromFile functions.

actual fun readFileText(path: String): String

Reads the text file at path. Throws if it cannot be read; in browsers, which have no file system, it always throws. Used by the sources' fromFile functions.

actual fun readFileText(path: String): String

Reads the text file at path. Throws if it cannot be read; in browsers, which have no file system, it always throws. Used by the sources' fromFile functions.

Link copied to clipboard
actual fun readResourceText(path: String): String?

Reads a text file shipped inside the app, or null if there is none at path:

actual fun readResourceText(path: String): String?

Reads a text file shipped inside the app, or null if there is none at path:

expect fun readResourceText(path: String): String?

Reads a text file shipped inside the app, or null if there is none at path:

actual fun readResourceText(path: String): String?

Reads a text file shipped inside the app, or null if there is none at path:

actual fun readResourceText(path: String): String?

Reads a text file shipped inside the app, or null if there is none at path:

actual fun readResourceText(path: String): String?

Reads a text file shipped inside the app, or null if there is none at path:

actual fun readResourceText(path: String): String?

Reads a text file shipped inside the app, or null if there is none at path: