Splitties
Splitties copied to clipboard
Add lint error when views are added in lParams lambda
Can you spot the error in the snippet below?
add(::verticalLayout, lParams(width = matchParent) {
val inputLParams = lParams(width = matchParent)
add(firstNameInput, inputLParams)
add(lastNameInput, inputLParams)
add(emailInput, inputLParams)
add(mobilePhoneNumberInput, inputLParams)
})
Here's the fixed version:
add(::verticalLayout, lParams(width = matchParent)) {
val inputLParams = lParams(width = matchParent)
add(firstNameInput, inputLParams)
add(lastNameInput, inputLParams)
add(emailInput, inputLParams)
add(mobilePhoneNumberInput, inputLParams)
}
Did you notice? I hopefully managed to notice my mistake. I added the views from the lParams lambda instead of from the add lambda, which made them be added to the parent of the verticalLayout instead of in the verticalLayout itself.
A lint should be able to catch such mistake and show an error