Comments (4)
I've read this comment and I just double-checked.
My ShowRootScreen
is a destination, but the call to DestinationNavHost
inside of it uses another NavGraph
DestinationsNavHost(
navGraph = NavGraphs.showRoot,
[...],
)
from compose-destinations.
Hi @lucanicoletti , I'm sorry it took me so long to get back to you. I hope you found a workaround in the mean time 🙏
Let me start by making something clear:
Inside this inner DestinationsNavHost the screens marked with the ShowRootNavGraph are added with the composable(Destination) { Screen() } function.
This is not adding screens. Differently from official compose navigation library, the screens are added when you pass one NavGraph to the DestinationsNavHost, since that nav graph has information needed to add all its nested graphs and destinations.
This is just overriding the common way the library calls the annotated Composables, by manually calling them. Usually useful when you want to pass some compose state from the NavHost level down to the screen level.
Besides this, it's really hard for me to understand exactly what's happening, but it does sound like a complicated setup, probably unwarranted.
The "show root" nav graph, passed to the inner DestinationsNavHost, means that all screens of that nav host, can only navigate to other screens of that graph. So, if you're trying to navigate to a screen registered to the outer "root" graph, that would require using a NavController from that graph, otherwise the crash you're experience is to be expected (I can't answer to the seemingly random factor, if it is indeed there, it will be caused by official library that we use to navigate, not caused by Compose Destinations).
Maybe you can show me the contents of your NavGraphs generated object.
Let me know if this helps!
from compose-destinations.
No worries for the late reply. As you've guessed, I found a "solution". I would like to contribute more, but I'm unsure with what I can share.
The "solution" was to inline a function.
The "outer" DestinationNavHost
in the MainActivity
was navigating the ShowRootSceen
, and that screen had a Scaffold
, which called a function MyNavHost
which inside used the second and inner DestinationNavHost
.
I don't know why, but moving the code from MyNavHost
inline inside the Scaffold
of the ShowRootScreen
removed the problem.
Perhaps without having the composable(destination) { MyScreen }
directly inside of it, the navHost
wasn't able to recognise the graph and its routes/destinations?
from compose-destinations.
No, that’s not needed.
anyway, glad you found a solution! I’ll close this, don’t hesitate to open something if you find another issue
from compose-destinations.
Related Issues (20)
- Destination for multi module project. HOT 2
- Preserve top-level screens for bottom bar HOT 2
- Crash Caused by android.os.RemoteException while calling navController?.navigate(PipOverlayScreenDestination) HOT 1
- Bottom Sheet Navigation Different Behavior Requirement HOT 1
- Using ModalBottomSheetLayout always fallsback to startdestination when configuration changes HOT 2
- BottomSheet onDismiss callback possible? HOT 1
- Combine Destination annotations HOT 7
- Lifecycle for screens that then shows a dialog HOT 1
- ArrayList<Enum> nav args crashing HOT 6
- Unresolved reference: rememberAnimatedNavController HOT 1
- [Question] How to navigate from ViewModel? HOT 1
- DestinationStyleBottomSheet with LazyColumn scroll issue HOT 2
- DestinationStyleBottomSheet transition from BottomSheet not smooth HOT 4
- ModuleRegistryKt is defined multiple times in Multi-Module project HOT 5
- Support for navigation material HOT 2
- [ksp] NullPointerException | UtilsKt.toImportable HOT 7
- [KSP] NullPointerException HOT 23
- What does `navigators` argument in `engine.rememberNavController()` do? HOT 1
- KSP option for single destination invoke() function HOT 2
- Bottom Sheet navigation problem when onlyIfResumed = true HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose-destinations.