Previous episode: 25. Create a Filter Widget
Next episode: 27. Challenge: Add a Filter
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.
In the last episode, you created a singular widget to filter out the results of the courses. Now it's time to create a page for these widgets. Here's what the final result will look like. Can you think about how this page is organized? The top level widget is a scaffold that will contain an app bar. We want to put all the filter widgets in a stack. A good widget for this is a column. We will pass in an array of filter widgets. Okay, that's the plan. Let's put it into action. To get started, open up your project in progress or download the sample project for this episode. Now we're going to build out the filter page using our new filter widget. Open up FilterPage.dart, located in the Filter sub folder. Add a property to FilterPageState to hold the currently selected filter value. Then, import Constants.dart. Add a private message that will be called when the selected filter changes. You call setState to update the state of the filter page filter value. If there is a null value, you set the filter value to zero. Inside the build method, update the body so that it contains a column of filter widgets. Add one for each domain. First, import the filter widget. Then, add the following to your build method. All right, your filter page is good to go. Now build and run, or hot reload the app in progress. We've left out one important filter, but you'll fix that in the next challenge.
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.