Previous episode: 28. Use Shared Preferences
Next episode: 30. Conclusion
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.
Filter page is now working, but we've not done anything yet to filter courses. We'll get that working in this episode. However, we'll also notice a deficiency in our approach and that will lead us into the next part of this course. A lifting state up in the app. To get started, open your project in progress or download the sample project for this episode. Now run your app. Open the filter page and select a filter. Go to the courses page and you'll see that our course listings aren't being filtered. Let's give that a shot now. In the UI courses folder, open up coursepage.dart. Add a filter value for the state of the page. We'll add a load value method that looks like the one you added earlier on filter page. In fact, we'll copy what we wrote. Open up filterpage.dart. Copy init state and paste it into coursepage.dart. Do the same for load value. Once pasted, make sure to import shared preferences. Now in our call to the controller, pass in the filter value property so that we fetch courses for the currently selected filter. Now, indeed, I see the filtered courses when the app starts. So that's great. But if I go to the filter screen and filter to our different course and then go back, the course page does not update to show the newly selected filter. We are only setting the state on the courses page when it first starts. And selecting a new filter on the filter page has no effect. This gets into the important topic of state management on Flutter, which is the subject of the final part of this course.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.