Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

navArgs class from another module cannot have fields with default values #108

Open
Sannedak opened this issue Apr 18, 2022 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@Sannedak
Copy link

Hi! I want to make module "navigation" where will be placed all navigation args, but have compilation error:
There was an issue with 'navArgsDelegate' of composable 'ArticleDetailsScreen': make sure it is a class with a primary constructor

Minimal reproducible repo

In ArticleDetailsNavArgs instead of just id I want to pass object in the future. I don't want to duplicate exact the same object in another modules and map one to another.

Thanks for your work! Awesome lib!

@raamcosta
Copy link
Owner

raamcosta commented Apr 19, 2022

Hi @Sannedak !

This is not how this library is designed to work. The navigation module depends on all others, not the other way around. The navigation module builds a Navigation graph (from the outputs of each module) and calls the DestinationsNavHost passing the graph.

I suggest you check my two multi module forks of very well known developers in the community Chris Banes and Philipp Lackner:

@raamcosta raamcosta added the question Further information is requested label Apr 19, 2022
@raamcosta raamcosta changed the title NavArgs cannot be used in multi-module project navArgsDelegate must use a class from same module Apr 19, 2022
@raamcosta raamcosta added enhancement New feature or request and removed question Further information is requested labels Apr 19, 2022
@Sannedak
Copy link
Author

Thanks. I'll continue to use arguments duplication for now.

@cvb941
Copy link

cvb941 commented Sep 22, 2022

I'm encountering the same issue.

In my case, I'm using a data class from a shared KMM module as a navArgsDelegate for screen @destinations in an android app module.

@raamcosta raamcosta changed the title navArgsDelegate must use a class from same module navArgs class from another module cannot have fields with default values Mar 12, 2024
@raamcosta
Copy link
Owner

This works now, but the class cannot have default values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants