https://kotlinlang.org logo
#compose
Title
# compose
n

Nthily

12/12/2021, 2:21 PM
I'm trying to set up the startDestination page based on whether the room database has the specified value, but it keeps getting this error
k

K Merle

12/12/2021, 2:39 PM
You could do a calculation in splash screen if possible.
i

Ian Lake

12/12/2021, 4:21 PM
First of all, this isn't how you should be handling login in Navigation, this is something we've covered a couple of times: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1630878904292300?thread_ts=1630873265.287300&cid=CJLTWPH7S
Secondly, this isn't how you pass arguments to your start destination: the start destination string needs to match the route string exactly, character by character. You'd use the
defaultValue
on your argument: https://github.com/google/accompanist/issues/897
But again, you shouldn't need to do that at all
Passing your userId as an argument is generally going to lead you to source of truth issues - Room is your source of truth so your Home screen should be your start destination and collectAsState() on your Room DB to get the current user, conditionally redirecting the user to login if the current userId is null
👍🏻 1