This part is use to introduce your application
If you are totally new to Flutter or not know what is it, you probably will want to read Flutter's document first. Or, if you do not install Flutter on your computer yet, please follow Flutter official install instruction to set up everything.
Step 1: Clone the repository from GitHub:
$ git clone https://github.com/hieuvh3011/flutter_show_off.git
or fork it from repository. If you don't know how to fork, check this.
Step 2: install all dependencies:
$ flutter pub get
Step 3: Run project on virtual machine Open your simulator (to simulate iOS devices) or emulator (to emulate Android devices) and then run
$ flutter run
inside your project's terminal. And then we done!
Step 4 (optional): run automation test cases
$ flutter test
If you are developing app and want to build .apk
file or .ipa
file for testing purpose, only need to run
$ flutter build apk
to generate .apk
file, or
$ flutter build ipa
to generate .ipa
file.
When we are ready to build a release version of the application to deploy on the store, everything will be more complicated. Flutter team describes it very detailed about Build and release Android app and Build and release iOS app in their document. And I think I cannot do it better than them. So, please follow Flutter's official instructions for that.
This is a list of 3rd party library we use inside of application. Every time we add a new library, we will list it in here to keep in track.
The list is:
- Dio to call Http request.
- Flutter StatusBar Color to control color of Status Bar inside app.
- Provider to manage global state in application. Suggested by Flutter team in their official document.
- Flutter Localization, a library suggested by Flutter team (read here) to support multiple language in app.
- Shared Preferences to store small pieces of data (like caching data)
- Test and Mockito for testing purpose, follow Flutter testing documentation
- Carousel Slider for make a carousel in HomeScreen
- Easy Localization for localization in app
From my experience, I will use the structure below. If you guys find anything unreasonable or can be improved in this structure, please let me know.
lib
: this folder to contain the main code part of our applicationapp
: this folder contain parent widgets of applicationbusiness_logic
: this folder use to contain the main business logic inside of application . Example, for now, this part will containapp_date_time.dart
to process all of date time logic inside of app.entities
: this folder contain the entities using for client side in app.repository
: is the repository of app.database
: using for store caching data into local database. Some data will not always need to call from backend.network
: to get data from server side
res
: the folder contain all resource of applicationfonts
: custom font using in appimages
: all images using inside appstrings
: all strings inside app. For now, this app have only 1 language. But we can add more language later by adding more JSON file into this folder. For example:thai.json
,vi.json
, ect.
route
: manage route (navigation) inside of applicationutils
: folder to store any kind of helper that you have, such as Themes, Colors, Images Directory, etc.store
: this is a state management part in this application. I've separated the state and UI of the app into two separate layers. This layer use to manage state in app.screen
: this is a UI layer. All files in here have only 1 mission: display UI of app.
main.dart
: entry point of your application as per Flutter standards.
In this part, we will define rules for the whole project. Rule could be changed, but every developer need to follow it. Otherwise, source code will be inconsistent
- name of files and folders: using snake_case rule. For example:
account_screen
(notAccountScreen
, notaccountScreen
) - name of variables: using camelCase rule. For example
var splashModel;
- name of class: using PascalCase rule. For example
class SplashScreen extends StatelesWidget
Read more about type cases in here
... to be continuing