Package dagger
Annotation Type Provides
-
@Documented @Target(METHOD) @Retention(RUNTIME) public @interface Provides
Annotates methods of a module to create a provider method binding. The method's return type is bound to its returned value. The component implementation will pass dependencies to the method as parameters.Nullability
Dagger forbids injecting
null
by default. Component implementations that invoke@Provides
methods that returnnull
will throw aNullPointerException
immediately thereafter.@Provides
methods may opt into allowingnull
by annotating the method with any@Nullable
annotation likejavax.annotation.Nullable
orandroidx.annotation.Nullable
.If a
@Provides
method is marked@Nullable
, Dagger will only allow injection into sites that are marked@Nullable
as well. A component that attempts to pair a@Nullable
provision with a non-@Nullable
injection site will fail to compile.