NavigationEventInfo


public abstract class NavigationEventInfo

Known direct subclasses
NavigationEventInfo.None

A default used when no specific information is associated with a navigation event.


Provides contextual information about a navigation state (e.g., a screen or route).

Implement this interface on objects that represent a specific state in your UI. A typical implementation should be a data holder (such as a data class) that defines meaningful structural equality (equals/hashCode). This ensures that navigation state comparisons, state flows, and recompositions work as expected. Failing to provide proper equality can lead to unnecessary recompositions or infinite update loops.

Guidelines for implementors:

  • Prefer data class to automatically provide equality and toString.

  • Keep instances immutable for predictable behavior in state flows.

  • Ensure equality reflects the logical identity of the navigation state.

This allows you to associate custom, comparable data with a system navigation event emissions.

Summary

Nested types

public static class NavigationEventInfo.None extends NavigationEventInfo

A default used when no specific information is associated with a navigation event.

Public constructors

Public methods

String

Defines the title of the navigation destination.

String

Defines the URL or path representation of the navigation destination.

Public constructors

Added in 1.0.0
public NavigationEventInfo()

Public methods

getTitle

Added in 1.2.0-alpha03
public String getTitle()

Defines the title of the navigation destination.

Host environments can use this value to represent the active destination (e.g., a web browser's tab title).

Follow these best practices:

  • Localization: Localize or translate the value.

  • Resolution: Resolve resource IDs to strings before returning.

  • Formatting: Interpolate dynamic parameters directly (e.g., "Details - $id").

Defaults to null, meaning the title remains unchanged.

getUrl

Added in 1.2.0-alpha03
public String getUrl()

Defines the URL or path representation of the navigation destination.

Host environments can use this value to update their location display (e.g., a web browser's address bar).

For web environments, this supports:

  • Full URL (e.g., "https://example.com/home"): must match the active origin.

  • Relative path (e.g., "/home"): appends to the active origin.

  • Hash fragment (e.g., "#home"): triggers a hash navigation.

Defaults to null, meaning the location remains unchanged.