The goal is to inject a class with an optional constructor parameter.
If using @Inject the class will be created without the optional parameter, while if I want to pass the optional parameter I can use a factory @AssistedFactory.
I am trying to achieve it like this:
class ClassName @AssistedInject constructor(
private val database: FirebaseFirestore,
private val functions: FirebaseFunctions,
@Assisted private val division: String?
) {
@Inject constructor(
database: FirebaseFirestore,
functions: FirebaseFunctions
) : this(database, functions, null)
}
But it throws an error when I am injecting ClassName
without using a factory
error: Dagger does not support injecting @AssistedInject type, ClassName. Did you mean to inject its assisted factory type instead?
How can I achieve the goal above? Any help is much appreciated