r/FlutterDev • u/khoahoang668 • May 30 '20
Example A Completed Functional Flutter App - FindSeat (BLoC + Json API + Unit Test + Firebase Auth)
I’m Android Developer and I’m working in a software company in Vietnam. I have experience in both kind project: outsourcing project and product project. I decided to study Flutter, because I believe it’s promised in future. As experienced developer, I care about clean architecture, testing, performance and maintainability that why I keep searching for an example of completed application. Unfortunately, community now full of project such as speedcode, UI challenges, … it’s just small pieces of real world application. In fact, most of the project doesn’t have fancy UI like that. That why I build this project by myself and now share it to the community, I hope you can get something from it then apply to your work.
The first version of project (v1.0) is just about UI + simple logic. In this version v2.0, I applied BloC pattern by using Flutter Bloc to project and also have unit tests for it. I also built simple Mock API for the app, it just static json file uploaded to a my private hosting. I hope I have time to do cache local data by SQLite but I have not, so hope next version will be soon available.
Check the soure code here
2
u/jagdishjadeja May 30 '20
you can build its flutter web version and link to github pages too
2
u/khoahoang668 May 30 '20
yeah great idea. I will make web version soon. Tks
3
u/fyzic May 30 '20
You might want to use moor or hive for the local cache because sqflite doesn’t support web
1
u/khoahoang668 May 30 '20
yeah you're right. I didnt look at the different in web yet, some packets might not work in web so ... yeah, let see
2
u/AGlorie Jun 01 '20
I'd recommend hive for local database, very easy to implement and very fast
1
u/khoahoang668 Jun 02 '20
Thank you. I will take a look at that. Maybe caching will be implemented in next version.
2
u/YellowSecurityLine May 30 '20
Are you free to work for my project? PM me please .
2
2
u/vedantrathore May 30 '20
I'm also a flutter dev available to work on paid projects. You can DM me if interested.
2
May 30 '20
Nice work, can I ask how long did it take you to finish it as a professional?
2
u/khoahoang668 May 30 '20
Hi. thank so much for your question.
Honestly, I don't know extractly how long. My first line of code written at the beginning of Dec 2019, it's about 7 months.
My main job is Android dev so I do this project only when I have time. It can be at night or weekend. That why it's hard to measure the time but I think if I can spend 8 hours per day for it. It can be shorter, maybe ~2 months I guess.
2
u/hrafios May 30 '20
How long do you think it would take to do the same app in native android (shorter period of time or longer)
2
u/khoahoang668 May 30 '20
Let say I have 6 years in Android and in Flutter, I have only 1 year(just beginner) So I belive if I do it in native Android, it can be faster :D
2
u/sailorfree May 30 '20
Great job and thank you! What are your thoughts as to the differences between flutter development and android development? What do you think are the problem areas for flutter development?
3
u/khoahoang668 May 31 '20
Thanks for your good question. To answer your question I think it can be quite long so I will try to explain by all my best.
1. Customview, ViewGroup, Fragment - Widget and widget, everything is widget
I believe that so many Android developer must do customize UI following iOS style because the client love iOS, they want Android app must be the same with iOS app that why writing Customview, ViewGroup is a part of developer’s job. In building it, you also need to write its behavior like response to user’s clicks, animation, show/hide icon, color when state changed, etc .
The interesting thing here is when your UI big and complex enough such as calling API, access local database, read/write file to gather data needed so Customview, Viewgroup doesn’t suite anymore because they doesn’t have lifecycle but Fragment do, that why you need Fragment.
You will feel like home in Flutter because everything is widget, you will working with widget most of the time so you no need to worry about when to use Customview, ViewGroup or Fragment.
2. No more boilerplate code when building Collection View
In order to build a collection view to display a list of data, you need to declare item row layout UI in xml and class Adapter (when working with ListView and RecyclerView). After that, you need to bind each field of object to view one by one, declare interface to handle item click, … a lot of tedious task need to be done.
In Flutter, thing can be done easier and faster.
3. Creating UI in Flutter is super fast
In Android, there’re 2 common methods in creating rounded rectangle button. Write your CustomView or Xml Drawable. Thank for Flutter widget, there’re a lot of widget built-in and easy to customize or extends.
In creating new screen in Android, you need to do steps like below:
- Step 1: Define a class extends AppCompatActivity
- Step 2: Define an xml layout file for UI
- Step 3: Declare activity class in AndroidManifest.xml
- Extra: if you also need a fragment inside Activity, you will repeat whole steps again.
Even Android Studio provide some snipet that help developer can do these steps faster but in practice, you need to complete whole the stuff. So in Flutter, it’s simpler than that.
4. Passing data between screens
Hand up if you feel painful and frustrated when working with Parcelable. Thing is easier in Flutter, if you need passing data to a screen, use constructor.
5. Other things about Flutter
- Comunication between widgets is not really straightforward, I don’t really like InheritedWidget approach
- Android tried to avoid nested UI components but Flutter widgets are nested
- Codebase can be very large in a single file
- In preview changes, Flutter hot reload better than Instant Run
- Google map plugin is not stable yet. Due to this and this
- Your app UI can follow Android style or iOS style or even mixed, depend on your own not OS
6. And more
- In Android, communicate between components is not really straightforward: between fragment and activity, betwen widget from child to parent. In Flutter, it very simple
- Because everything is widget, so code base in flutter can be very large in single file
- Android tried to avoid nested UI components, Flutter widgets are nested.
- In preview UI changes, Flutter hot reload better than Instant Run
- Google map plugin is not stable yet
- You can define Hex color in Android (ex: white = #ffffff) but in Flutter it need to define custom class in order to use
- When you when to accesss resources such as image, color, i18n, ... Android required you context and R class but in Flutter it more simple
And may be more but I'm just flutter beginner so let wait and see :D
2
2
6
1
u/kokemomuke May 31 '20
Which part of code use, main_dev or main_prod?
I builded from source codes, but can not login by using test account.
1
u/khoahoang668 May 31 '20
- Which part of code use, main_dev or main_prod?
=> this is build variant config. main_dev is development and main_prod is production. Please check class AppConfig then you will understand
- I builded from source codes, but can not login by using test account
=> Please check the log, what does it say
2
2
2
2
5
u/escamoteur May 30 '20
Why do you call it fully functional?