I have a FooViewModel
that is scoped to the FooFragment
. In FooFragment
, the device type is passed from another fragment based on what user selects. I want to inject this in the constructor of the FooViewModel
. How should I provide the deviceType
in the module?
Here’s my setup –
@Module
interface FooModule {
@ContributesAndroidInjector
fun contributesFooFragment(): FooFragment
companion object {
@Provides
fun provideDeviceType(fragment: FooFragment) = fragment.deviceType
}
}
I get an error
[Dagger/MissingBinding] FooFragment cannot be provided without an @Inject constructor or an @Provides-annotated method. This type supports members injection but cannot be implicitly provided.
...
New contributor
Salil Rajadhyaksha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.