toBooleanStrictOrNull

Returns true if the content of this string is equal to the word "true", false if it is equal to "false", and null otherwise.

fun String.toBooleanStrictOrNull(): Boolean?(source)
fun main() {
    val testStrings = listOf("true", "false", "True", "yes", "")
    for (s in testStrings) {
        val result = s.toBooleanStrictOrNull()
        println("Input: \"$s\" → $result")
    }
}

Source