Is it possible to create an annotation so that whe...
# dagger
b
Is it possible to create an annotation so that whenever I use that annotation it gives me an item. I'm trying to do something like this
Copy code
class MyClass @Inject constructor(
  @Tablet isTablet: Boolean
)
Then in my module I have something like
Copy code
@Provides
@Tablet
fun provideIsTablet(context: Context): Boolean = someWayToTellIfTablet
Is there a way to create an annotation like this without have to use
@Named("Tablet")
n
You want a
@Qualifier
.
Copy code
@Qualifier
annotation class Tablet
Create this class with the annotation and your snippets will work as is.
b
Thank you!
👍 2
c
If I'm not mistaken, @Named is technically a qualifier, but yeah if you want your own custom one then you create a custom qualifier.
j
Named is not special, yes, it's just a qualifier
c
Holy crap. I had some input on a dagger conversation. Does that mean I'm finally learning? 🤣
🎉 8