Kotree
A simple tool to display a text tree with Jetpack Compose.
root
βββ a
β βββ c
β β βββ j
β β βββ k
β β βββ l
β βββ f
βββ d
βββ g
βββ h
fun main() {
println(
kotree {
Content()
}
)
}
@Composable
private fun Content() {
Node("root") {
Node("a") {
Node("c") {
Node("j") {
Node("k")
Node("l")
}
}
Node("f")
}
Node("d") {
Node("g")
Node("h")
}
}
}
Not only can you draw the tree manually, but you can also visualize the structure.
sampleproject
βββ src
β βββ commonMain
β βββ kotlin
βββ build.gradle.kts
βββ settings.gradle.kts
@Composable
private fun FileNode(file: File) {
Node(file.name) {
file.listFiles().forEach {
FileNode(it)
}
}
}