Dùng Compose Navigation library với NavController và NavHost.
- Định nghĩa
NavGraphvới các màn hình và route, rồi dùngnavController.navigate(route)để điều hướng. - State được giữ lại khi quay về màn hình trước.
- Với Compose Navigation 2.8+ (stable từ Oct 2024), dùng type-safe routes qua
@Serializablethay vì string-based routes.BackHandlercho phép tùy chỉnh hành vi nút back.
Use the Compose Navigation library with NavController and NavHost.
- Define a
NavGraphwith screens and navigation routes, and usenavController.navigate(route)to navigate. - State is preserved when returning to previous destinations.
- Compose Navigation 2.8+ (stable Oct 2024) introduced type-safe routes via
@Serializable— use these instead of string-based routes.BackHandlerallows custom back button behavior.