Flutter Navigator 2.0

Nov 8 2022 · Dart 2.17.3, Flutter 3.0.2, Android Studio 2020.3

Part 3: Use the Navigation

15. Navigate to the Detail & ReadBook Pages

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 14. Navigate to the Cart & Settings Pages Next episode: 16. Go to the Previous Page

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Transcript: 15. Navigate to the Detail & ReadBook Pages

Episode - 15 Navigate to Detail And Readbook Pages

Let is write the navigation of the details page. When we click on the book tile on the home page it takes us to the detail page. Come to homeScreen and in the onTap function in the Grideview Write the bookTapped Function from the BookManager class.

Provider.of<BookManager>(context, listen: false).bookTapped(index);

Here we pass the index that we click on the GrideView. Now let us write the condition to show the detailPage. Go to BookRouterDelegate and write the code. We first make sure that the selectedIndex n the book manager is not equal -1. and onCart and onSettings from appStateManager is not true.

if (bookManager.selectedIndex != -1 && !appStateManager.onCart && !appStateManager.onSettings)DetailsScreen.page(book: bookManager.selectedBookItem, index: bookManager.selectedIndex),

Reload the app and check the after clicking on any tile in the gride view it will take us to DetailPage.

Let us write the code to show the ReadBookPage Screen on the DetailScreen where the onPressed function of the readBook button add the onReadBookTapped function.

Provider.of<AppStateManager>(context, listen: false).onReadBookTapped(true);

As usual let us go to pages part where we write all the logic and condition of our navigation page.

  if (appStateManager.onReadBook &&
           bookManager.selectedIndex != -1 &&
           !appStateManager.onCart &&
           !appStateManager.onSettings)
         ReadBookScreen.page(bookManager.selectedBookItem),

The logic Condition here is that we check if the onReadBook is true is selctedIndex is not equal to -1, This means that we have a selected book. And onCart and Setting check is false. Now restart the app check if our app working as expected like detail screen and readbook page.