In this line:
note = intent.getSerializableExtra(EXTRA_NOTE) as Note
Note
is a non-null type, so the cast to it triggers a null check. Since you’re comparing note
to null
manually afterwards, probably you meant the safe cast operator, which yields null
if the expression is not of the type specified in the right-hand side:
note = intent.getSerializableExtra(EXTRA_NOTE) as? Note