Hi. I need to open a BottomSheetFragment on button...
# effective-kotlin
k
Hi. I need to open a BottomSheetFragment on button click. What is the better approach 1- Should i create a global instance and create it once
Copy code
val dialog by lazy { Dialog() }
2- Should i create it inside method each time button is clicked
Copy code
btn.setOnClickListener { showDialog() }

fun showDialog() {
    Dialog().show()
}
f
#2
👍 1