Personal Account Application

Guqung
Flutter Community
Published in
3 min readMar 11, 2020

I published a flutter project in GitHub(https://github.com/guqun/xiaoer) which implements account function. This project is a complete application that contains the core functions of accounting.

Next, I will introduce the project framework which was valuable and I completed the whole project in one month. I wish that this framework could help freshmen quickly to build flutter application.

  1. Bloc pattern is basic framework

The project uses BLOC pattern(flutter_bloc plugin), all bloc files are in bloc directory which contains bloc_event, bloc_state, bloc. bloc_event defined bloc event(e.g. refresh page event), bloc_state defined current stream control status(e.g. query data success status), bloc mainly deals with business logic。How to use flutter_bloc, please click https://pub.dev/packages/flutter_bloc.

2. Data Model

Using Bloc pattern could separate view and business logic. How to separate business logic and data model. I add a repository layer to avoid logic and model in a file. All data used by business logic was generated in the repository layer. Now, all data was stored locally except the current rate which was queried from RapidAPI. If we change the data source, we just need to adapter repository layer, which is convenient.

3. Network query

In this project, Querying network data uses dio plugin. For convenience, I packaged dio into tool class. For instance,

static Future<BasicResult> queryMeInfo() async
{
return HttpUtil().request(HttpUrlConst.me_info, HttpType.get);
}

In the tool class, We could deal with common information(e.g. public error, public query params). The result was in BasicResult class.

3. Common Dialog

I customize three common dialogs. one is used to submit confirm which has two-button (ok and cancel). The second is used to select items, e.g. Record type is expenses or outcome. The last one is the loading dialog. these dialogs could improve the speed of coding.

4. Others

a.Data Storage

I choose sqflite plugin to operate database and shared_preferences plugin to operate local persistence.

b. Navigator Util

I choose fluro plugin to manage pages.

--

--