Flutter Standard

Flutter Code Standard 2021


Other than MNC Code standard, flutter has more goal

  • Standardize and unified way of code
  • Beginner Friendly and flattening learning curve, since


  • Project Structure Standard
  • Best Practice
  • Security Standard
  • Layout Standard
  • Third Party Standard
  • Documentation Standard

Structure and Project Standard

The structure and design pattern are inspired by clean architecture and MVC, because those are then most common things that developers known.


The structure of the project are like this

│─── common
│  │   ...
│─── core
│  │   ...
│─── module
│  │   ...
│─── main.dart 

Common used widget, utils, and model in every module.

Core for global & application logic placed.

Module for your every modules located


Developer have to define and implement

Core Image
Core Structure
App Version ManagerApp version manager are for app updater, to make sure the app have newest version
AssetsAssets static file name
DeeplinkDeeplink handler
EnvironmentEnvironment variable, constant manager, and security
Global ControllerGlobal Controller Manager
Base NetworkBase Network of your project
Notification HandlerNotification Handler for your project
RouteRoute Definition of your project
StyleStyle definition for your project


Place your ui and business logic in this folder, and it has this pattern

Module Pattern
Module Pattern
ControllerThe Controller module represents the logic of data flow within the application. It is the middle layer between the Repo and Screen layers. The Controller is responsible for updating the pipe when the data changes.
DataThe Data module defines the IO logic of the application. This module must have a Repository the source data can be various and send data to Controller.
ScreenThe Screen module represents entry point of route and page of app.
TestThe Test module are place for current module unit, widget and integration test.
WidgetThe Widget module are place for current module widgets.


Common only contain model, widget, and utils

Best practice

  • Use Flutter 2
  • Follow Flutter Performance Best Practice
  • Follow Dart Style
  • Use snake_case for every developer created file under lib folder, ex login_screen.dart, money_utils.dart, my_widget.dart
  • Split Into 3 Environments Staging, Beta, Production
  • Use VSCODE
  • Use Named Route
  • In model use PODO (Plain Old Dart Object) for easier maintainability
  • Every function name in repository must have prefix repo, ex repoYourFunc()

Security Standard

  • Save Credential Token like JWT token in Secure Storage, not SQL, SharedPrefences, NSUserDefault
  • Avoid print(somevar), use debugPrint or log
  • Add Url validator in deeplink handler, avoid sql injection or such
  • Ignore every credential file in git

Layout Standard

  • Use MaterialApp
  • A Widget must in class, avoid function
  • Make sure layout in width 300px are safe from widget overflow.
  • Avoid large trees, split your code into small widgets instead. Max in a UI Layers has 500 lines
  • Use Theme
  • Use Color Theme first
  • Avoid Hard Coded String in Text content

Third Party Standard

  1. There is no limitation for 3rd party UI Library make sure avaialable for flutter 2.
  2. But if the library has OS functionality like bluetooth, camera etc. please use the library which created by google team, then most popular
  3. Use these library for any mnc flutter project
    • State Management > GetX
    • Route Management > GetX
    • Dependency Management > GetX
    • Network > Dio
    • Firebase Crashlytic
    • Firebase Performance Monitoring
    • Firebase Analytic

Documentation Standard


Download Presentation