# ViewModelProviderGetKt

Added in 2.5.0

*** ** * ** ***


```
public final class ViewModelProviderGetKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull VM` | `@https://developer.android.com/reference/androidx/annotation/MainThread <VM extends https://developer.android.com/reference/androidx/lifecycle/ViewModel> https://developer.android.com/reference/androidx/lifecycle/ViewModelProviderGetKt#(androidx.lifecycle.ViewModelProvider).get()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/ViewModelProvider receiver)` Returns an existing ViewModel or creates a new one in the scope (usually, a fragment or an activity), associated with this `ViewModelProvider`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull VM` | `@https://developer.android.com/reference/androidx/annotation/MainThread <VM extends https://developer.android.com/reference/androidx/lifecycle/ViewModel> https://developer.android.com/reference/androidx/lifecycle/ViewModelProviderGetKt#(androidx.lifecycle.ViewModelProvider).get(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/ViewModelProvider receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html key)` Returns an existing ViewModel or creates a new one in the scope (usually, a fragment or an activity), associated with this `ViewModelProvider` and the given `https://developer.android.com/reference/androidx/lifecycle/package-summary#(androidx.lifecycle.ViewModelProvider).get(kotlin.String)`. |

## Public methods

### get

Artifact: [androidx.lifecycle:lifecycle-viewmodel](https://developer.android.com/jetpack/androidx/releases/lifecycle) [View Source](https://cs.android.com/search?q=file:androidx/lifecycle/ViewModelProviderGet.kt+function:get)

```
@MainThread
public static final @NonNull VM <VM extends ViewModel> get(@NonNull ViewModelProvider receiver)
```

Returns an existing ViewModel or creates a new one in the scope (usually, a fragment or an activity), associated with this `ViewModelProvider`.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/lifecycle/ViewModelProvider#get(kotlin.reflect.KClass)` | (Class) |

### get

Artifact: [androidx.lifecycle:lifecycle-viewmodel](https://developer.android.com/jetpack/androidx/releases/lifecycle) [View Source](https://cs.android.com/search?q=file:androidx/lifecycle/ViewModelProviderGet.kt+function:get)

```
@MainThread
public static final @NonNull VM <VM extends ViewModel> get(@NonNull ViewModelProvider receiver, @NonNull String key)
```

Returns an existing ViewModel or creates a new one in the scope (usually, a fragment or an activity), associated with this `ViewModelProvider` and the given `https://developer.android.com/reference/androidx/lifecycle/package-summary#(androidx.lifecycle.ViewModelProvider).get(kotlin.String)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html key` | The key to use to identify the ViewModel. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/lifecycle/ViewModelProvider#get(kotlin.reflect.KClass)` | (String, Class) |