Skip to content

Project Structure

Mark G edited this page Jun 7, 2021 · 4 revisions

Overview

├── android
├── assets
│   ├── images
│   └── l10n
├── ios
├── lib
│   ├── components
│   ├── configs
│   ├── core
│   │   ├── classes
│   │   ├── extensions
│   ├── gen
│   ├── models
│   ├── modules
│   │   ├── forgot_password
│   │   │   └── components
│   ├── repositories
│   └── services
├── test
│   ├── fakers
│   ├── helpers
│   │   └── extensions
│   ├── mocks
│   └── modules
│       ├── landing
│       └── login
└── web

Platform Project

ios, android, web

They contain native projects so that we can open them with Android Studio or Xcode to build, run or configure it normally like you write the native app.

Source

lib It contains the source of the flutter project, where we write our hybrid code.

core

It contains extensions, utility, base classes of the app

componnents

It contains common widgets, which can be reused, such: alert, loading spinner...

configs

It contains all configs for the app, such: colors, base URL...

Also, we should not use direct values from config files, instead link them into gen/configs.gen.dart

part 'package:survey/configs/app.dart';
part 'package:survey/configs/factories.dart';
part 'package:survey/configs/routes.dart';
part 'package:survey/configs/colors.dart';

class Configs {
  static const app = _AppConfig();
  static final factories = _factories;
  static final routes = _routes;
  static const colors = _ColorsConfig();

  const Configs();
}

Then, we can access our configs like this

Configs.colors.red

models

It contains object models.

Also, each model name requires a suffix Info, such: UserInfo, BookInfo...

services

It contains the lowest layer class to work with HTTP requests, databases...

repositories

It contains the connecting layer class, combine data from service and feed to interactor

modules

It contains VIPER modules.

And, each module is a screen in the app (LoginModule, HomeModule..)

Assets

assets

It contains all app resources, such: images, fonts, localize strings...

For images and fonts, it will be generated by flutter_gen into gen/assets.dart

Test

test

It contains all test files.

Also, the structure inside the test directory should match with the lib directory structure, excepts fakers, mocks, helpers.

Clone this wiki locally