Do I have to null check every time before referencing an element in view binding?

86 Views Asked by At

So this isn't really a issue, I am just curious, do I really have to null check every time I use view binding? I find it a bit annoying having to put the question mark every time (binding?.[layout item]).

Can somebody please give me a solution to this if it's possible?

1

There are 1 best solutions below

1
On BEST ANSWER

The only reason you would be doing this is if you had marked the Binding object as nullable, e.g. lateinit var binding MainActivityBinding?. Which there is no need for.