HiltViewModelFactory

public final class HiltViewModelFactory


Summary

Public methods

static final @NonNull ViewModelProvider.Factory
create(
    @NonNull Context context,
    @NonNull NavBackStackEntry navBackStackEntry
)

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a NavBackStackEntry.

Public methods

create

@NonNull
public static final ViewModelProvider.Factory create(
    @NonNull Context context,
    @NonNull NavBackStackEntry navBackStackEntry
)

Creates a ViewModelProvider.Factory to get HiltViewModel -annotated ViewModel from a NavBackStackEntry.

Parameters
@NonNull Context context

the activity context.

@NonNull NavBackStackEntry navBackStackEntry

the navigation back stack entry.

Returns
ViewModelProvider.Factory

the factory.

Throws
kotlin.IllegalStateException

if the context given is not an activity.