Skip to content

Commit

Permalink
fix: Navigation primary constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Aug 14, 2024
1 parent e0bcf6b commit 0e1de5c
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.os.Bundle
import androidx.navigation.NavBackStackEntry
import kotlinx.serialization.Serializable
import kotlin.reflect.KClass
import kotlin.reflect.full.primaryConstructor

/**
* Sealed class representing the navigation arguments for the main navigation flow.
Expand Down Expand Up @@ -94,8 +95,7 @@ sealed class NavigationDestination {
}

private fun <T : NavigationDestination> createInstance(kClass: KClass<T>, bundle: Bundle?): T? {
val primaryConstructor = kClass.constructors.firstOrNull()
return primaryConstructor?.let {
return kClass.primaryConstructor?.let {
val args = it.parameters.associateWith { parameter ->
bundle?.get(parameter.name)
}
Expand Down

0 comments on commit 0e1de5c

Please sign in to comment.