@Antal Georgina is correct, Let me elaborate her answer,
The app:popUpTo
and app:popUpToInclusive
attributes are essential when you want to clear fragments or destinations off the navigation stack in Jetpack Navigation.
Here’s a quick recap of what these attributes do:
app:popUpTo:
Specifies the destination up to which you want to pop the back stack. The back stack will be cleared up to (but not including) this destination, unless app:popUpToInclusive
is set to true.
app:popUpToInclusive="true"
: If set to true, the destination specified in app:popUpTo will also be removed from the back stack.
Example:
<action
android:id="@+id/action_to_fragmentY"
app:destination="@id/fragmentY"
app:popUpTo="@id/fragmentX"
app:popUpToInclusive="true" />