WEBVTT

00:00.680 --> 00:02.600
We defined our screens.

00:02.600 --> 00:07.040
Now let's start implementing the navigation component in our app.

00:07.040 --> 00:11.510
The first step is to create the nav controller.

00:11.540 --> 00:16.280
The nav controller is the central API for the navigation component.

00:16.280 --> 00:24.650
It's stateful and keeps track of the backstack of Composables that make up the screens in your app and

00:24.650 --> 00:26.930
the state of each screen.

00:26.930 --> 00:33.620
You can create a nav controller by using the Remember Nav controller method in your composable.

00:33.620 --> 00:39.620
So here inside the Setcontent I'll create nav controller equals.

00:39.620 --> 00:48.500
To remember nav controller, you should create the nav controller in the place in your composable hierarchy,

00:48.500 --> 00:54.020
where all composables that need to reference it have access to it.

00:54.020 --> 01:01.610
This follows the principle of state hoisting that allows you to use nav controller and the state it

01:01.610 --> 01:10.250
provides via current Backstack entry as state method to be used as the source of truth for updating

01:10.250 --> 01:13.190
Composables outside of your screens.

01:13.190 --> 01:19.520
So the main purpose of nav controller is for navigating between Composables.

01:19.520 --> 01:26.510
The Remember Nav controller method is a function that it is called to create and remember the nav host

01:26.510 --> 01:29.390
controller instance across Recompositions.

01:29.390 --> 01:36.590
And by using this function, you can efficiently handle navigation in your Jetpack Compose app, ensuring

01:36.590 --> 01:41.810
that the navigation controller is correctly managed across Recompositions.
