Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lint error when views are added in lParams lambda #53

Open
LouisCAD opened this issue Mar 23, 2018 · 0 comments
Open

Add lint error when views are added in lParams lambda #53

LouisCAD opened this issue Mar 23, 2018 · 0 comments

Comments

@LouisCAD
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant