How can I have a navGraph
without a startDestination
?
I have a BottomSheet
fragment container. When some events are triggered I want to expand this BottomSheet
and load a fragment to its fragment container. Until one of those events are triggered I don't want the fragment container to have any fragment loaded. I want it to be empty.
But if don't supply a valid startDestination
to the navGraph
the app crashes with the exception:
IllegalStateException: no start destination defined
Is this possible? What would be the best way to handle this?
EDIT
I know I can supply a startDestination
programmatically. But this is not a graceful approach. It introduces clutter code that needs to be executed when the first fragment load needs to happen and it gets worse when that fragment needs arguments.
The goal is to skip supplying a startDestination
altogether.
First solution: Create empty fragment and set it as startDestination in graph
Second solution: Wait until event triggered and open BottomSheet with startDestination argument. Read argument of BottomSheet and change start destination