Flutter Tutorial: Building An Expense Manager App – 6

This is the sixth part of Expenses Manager app Flutter tutorial series where we are building an Expenses Manager app.


In the previous post, we completed all the functionalities of creating Category. In this part of our Flutter tutorial, we will add features for working with expenses. We will design the home page and also create a category selector using ChoiceChip widget.

Designing Dashboard Page

The home tab of our Expense Manager app will be a dashboard page. In this page, we will have:

  • Link to add new expense.
  • A Date Switcher.
  • List of expenses for a selected date.

Designing A Date Switcher

We will start by adding a date switcher for our app. Basically, we want to show current date and add buttons to change current date. The buttons should allow user to go back and forth by a day.

With the date switcher, the dashboard can start to look like this:

We have yet to implement onPressed functionality for icon buttons.

Add FloatingActionButton To Add Expenses

Next, we will add a button to add expenses. A FloatingActionButton would be the right choice for this purpose since it will be distinctly visible.

Add ListView To Show Expenses

Finally, we will have a list of expenses for the selected date shown. For this, we will use a ListView with sample expenses for now.

Our design so far should look like this:

Expense Manager Dashboard Design
Expense Manager Dashboard Design

Adding New Expense

Now let’s add functionality to the dashboard page. First we will add functionality to add new expense. Similar to what we have done for category, we will create a separate route for adding expenses.

A product business logic component will handle UI interactions as well as expenses data stream. Also the CategoryBloc shall be used to fetch list of categories as well.

Since, most of the functionalities for creating new expense is going to be similar to that of creating category, we will not repeat everything here. You can refer to the previous posts regarding:

Become A Flutter Expert With This Course

  • BLoC pattern implementation and
  • Working with StreamBuilder and data stream.

Rather, here we will build a Category selector.

Using ChoiceChip Widget In Flutter

Since, every expense will fall under a category, when creating a new expense we will have to select a category. For this selection we can make use of the ChoiceChip widget. This widget can enable to select one item from a list of chip widgets.

Get Category List By Listening To Category Stream

Use the StreamBuilder like before to listed to category list stream.

You can access individual category model using the list index.

Create ChoiceChip Widget

And in your ChoiceChip widget, you can use this model to show text as well as to set selected property.

Complete Implementation Using ChoiceChip Widget

The complete implementation could look like this:

Here, we are using the setState function to rebuild the entire page on each category selection. You can also avoid the entire rebuild by putting the value of selected categoryId inside a stream and using a StreamBuilder.

ChoiceChip Category Selector
ChoiceChip Category Selector

Link To Previous Posts

About the author