A set of extensions in addition to androidx fragment-ktx.
Add the dependency:
repositories {
mavenCentral()
google()
}
dependencies {
implementation("com.redmadrobot.extensions:fragment-ktx:1.3.6-0")
}
Extensions for Fragment
:
-
Fragment.addOnBackPressedCallback(enabled: Boolean = true, onBackPressed: OnBackPressedCallback.() -> Unit)
Create and add a new
OnBackPressedCallback
tied toFragment.viewLifecycleOwner
that callsonBackPressed
inOnBackPressedCallback.handleOnBackPressed
.
Merge requests are welcome. For major changes, please open an issue first to discuss what you would like to change.