Leveraging Kotlin Function Arguments Helper

Akbar Dzulfikar
Gravel Product & Tech
2 min readAug 9, 2023

plugin can help development faster

Kotlin Function Arguments Helper provides inspection quick fix for constructors or functions to add arguments with name and a default value.

Default Arguments: Flexibility Made Easy

With default arguments, you can set initial values for function parameters. This means you don’t have manually provide arguments when calling a function.

data class Person(
val id: Long?,
val firstName: String?,
val lastName: String?,
val age: Int?,
val address: Address?,
val contacts: List<Contact>?,
val education: Education?,
val occupation: String? = "Unemployed"
)

data class Address(
val street: String?,
val city: String?,
val state: String?,
val postalCode: String?
)

data class Contact(
val type: ContactType?,
val value: String?
)

enum class ContactType {
EMAIL,
PHONE,
SOCIAL_MEDIA
}

data class Education(
val degree: String?,
val institution: String?,
val yearGraduated: Int?
)

Imagine you have big data of class when you call it and you have to assign default arguments one by one, which can take a lot of your time

How to Use it?

Simply open your android studio,

go to preference -> plugins -> search Kotlin Function Arguments Helper -> install

Preferences

or you can check this link

and this is the example how to use the Kotlin Function Arguments :

inspection quick fix

by simply click the “Add missing constructor arguments”, the arguments are automatically filled.

Autofill arguments

Conclusion:

Kotlin’s function argument features simplify coding tasks by providing default values, named parameter clarity, varargs for flexibility, and destructuring declarations for efficient data handling. to make you more focus on building readable applications.

There are other plugins that are similar, for example, Kotlin Auto Fill that you can try.

How many of you using plugins for you IDE? comment bellow

--

--