Ideally I want to declare an extension function so...
# android
m
Ideally I want to declare an extension function so I can call like `FooBinding.inflateOrNull(): FooBinding?`but I can’t see how to do this. The best I have is:
Copy code
private fun <V: ViewBinding> inflateOrNull(inflateLambda: (LayoutInflater) -> V): V? {
    try {
         return inflateLambda(layoutInflater)
    } catch (e: Exception) {
         // some dodgy device that cannot find a resource
         return null
    }
}
e
FooBinding
needs to have a companion object for you to be able to write an extension that can be called like
FooBinding.inflateOrNull()
. since it's a Java class, it doesn't have a companion