KotlinPoet: how to generate a DSL with parameters
I'm trying to generate this Kotlin code that contains a DSL with a parameter:
listOf(
navArgument(QUERY_PARAM) {
type = NavType.StringType
nullable = true
defaultValue = null
},
)
Is there a better way to provide the parameters to the DSL than just build the string manually?
CodeBlock.builder()
.addStatement("listOf(")
.indent()
.beginControlFlow("%M(${queryParam})", MEMBER_NAME_NAV_ARGUMENT)
.addStatement([...])
.endControlFlow()...