analyzer
이 패키지는 Dart 코드의 정적 분석을 수행하는 라이브러리를 제공합니다.
MobX와 Provider를 사용하여 Flutter에서 만든 보일러플레이트 프로젝트입니다.
이 패키지는 Dart 코드의 정적 분석을 수행하는 라이브러리를 제공합니다.
애플 스타일 아이콘을 기반으로 한 Cupertino 위젯용 기본 아이콘 자산
fonts.google.com의 폰트를 사용하기 위한 Flutter 패키지입니다. HTTP 가져오기, 캐싱 및 자산 번들링을 지원합니다.
MobX용 플러터 통합입니다. 추적되는 관측 가능한 값이 변경될 때 자동으로 재구성되는 Observer 위젯 세트를 제공합니다.
MobX는 애플리케이션 상태를 반응적으로 관리하는 라이브러리입니다. 관찰 가능한 항목, 액션 및 반응의 힘을 활용하여 Dart 및 Flutter 앱을 강화하세요.
MobX용 코드 생성기로 @observable, @computed, @action를 사용하여 코드에 주석을 달고 Store 클래스를 생성하는 기능을 추가합니다.
Flutter 앱의 런처 아이콘을 업데이트하는 작업을 단순화해주는 패키지입니다.
Dart 클래스에 주석을 달아 JSON 간 변환을 위한 코드를 자동으로 생성합니다.
인터페이스와 구체적인 구현을 분리하고 앱 내 어디서든 구체적인 구현에 접근할 수 있도록 해주는 간단하고 직접적인 서비스 로케이터입니다.
Dart VM 및 Flutter용 NoSQL 지속 임베디드 파일 시스템 문서 기반 데이터베이스로 암호화 지원
IndexedDB 위에 기반한 웹용 NoSQL 지속 임베디드 데이터베이스
응용 프로그램의 결합을 분리하기 위한 Dart 스트림을 사용하는 간단한 이벤트 버스
{"sdk":"flutter"}{"sdk":"flutter"}^1.12.29^1.0.5^5.1.1^2.0.0^2.0.6+5^7.2.0^4.0.3^0.13.5^0.19.0^6.6.1^2.1.4^2.0.14^2.1.0^2.1.3^3.4.4^3.0.0^2.1.0{"sdk":"flutter"}^0.13.1^2.2.0^2.3.3^5.10.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A boilerplate project created in flutter using MobX and Provider. Boilerplate supports both web and mobile, clone the appropriate branches mentioned below:
The Boilerplate contains the minimal implementation required to create a new library or project. The repository code is preloaded with some basic components like basic app architecture, app theme, constants and required dependencies to create a new project. By using boiler plate code as standard initializer, we can have same patterns in all the projects that will inherit it. This will also help in reducing setup & development time by allowing you to use same code pattern and avoid re-writing from scratch.
Step 1:
Download or clone this repo by using the link below:
https://github.com/zubairehman/flutter-boilerplate-project.git
Step 2:
Go to project root and execute the following command in console to get the required dependencies:
flutter pub get
Step 3:
This project uses inject library that works with code generation, execute the following command to generate files:
flutter packages pub run build_runner build --delete-conflicting-outputs
or watch command in order to keep the source code synced automatically:
flutter packages pub run build_runner watch
In-order to hide generated files, navigate to Android Studio -> Preferences -> Editor -> File Types and paste the below lines under ignore files and folders section:
*.inject.summary;*.inject.dart;*.g.dart;
In Visual Studio Code, navigate to Preferences -> Settings and search for Files:Exclude. Add the following patterns:
**/*.inject.summary
**/*.inject.dart
**/*.g.dart
Here is the core folder structure which flutter provides.
flutter-app/
|- android
|- build
|- ios
|- lib
|- test
Here is the folder structure we have been using in this project
lib/
|- constants/
|- data/
|- stores/
|- ui/
|- utils/
|- widgets/
|- main.dart
|- routes.dart
Now, lets dive into the lib folder which has the main code for the application.
1- constants - All the application level constants are defined in this directory with-in their respective files. This directory contains the constants for `theme`, `dimentions`, `api endpoints`, `preferences` and `strings`.
2- data - Contains the data layer of your project, includes directories for local, network and shared pref/cache.
3- stores - Contains store(s) for state-management of your application, to connect the reactive data of your application with the UI.
4- ui — Contains all the ui of your project, contains sub directory for each screen.
5- util — Contains the utilities/common functions of your application.
6- widgets — Contains the common widgets for your applications. For example, Button, TextField etc.
7- routes.dart — This file contains all the routes for your application.
8- main.dart - This is the starting point of the application. All the application level configurations are defined in this file i.e, theme, routes, title, orientation etc.
This directory contains all the application level constants. A separate file is created for each type as shown in example below:
constants/
|- app_theme.dart
|- dimens.dart
|- endpoints.dart
|- preferences.dart
|- strings.dart
All the business logic of your application will go into this directory, it represents the data layer of your application. It is sub-divided into three directories local, network and sharedperf, each containing the domain specific logic. Since each layer exists independently, that makes it easier to unit test. The communication between UI and data layer is handled by using central repository.
data/
|- local/
|- constants/
|- datasources/
|- app_database.dart
|- network/
|- constants/
|- exceptions/
|- rest_client.dart
|- sharedpref
|- constants/
|- shared_preference_helper.dart
|- repository.dart
The store is where all your application state lives in flutter. The Store is basically a widget that stands at the top of the widget tree and passes it's data down using special methods. In-case of multiple stores, a separate folder for each store is created as shown in the example below:
stores/
|- login/
|- login_store.dart
|- form_validator.dart
This directory contains all the ui of your application. Each screen is located in a separate folder making it easy to combine group of files related to that particular screen. All the screen specific widgets will be placed in widgets directory as shown in the example below:
ui/
|- login
|- login_screen.dart
|- widgets
|- login_form.dart
|- login_button.dart
Contains the common file(s) and utilities used in a project. The folder structure is as follows:
utils/
|- encryption
|- xxtea.dart
|- date
|- date_time.dart
Contains the common widgets that are shared across multiple screens. For example, Button, TextField etc.
widgets/
|- app_icon_widget.dart
|- empty_app_bar.dart
|- progress_indicator.dart
This file contains all the routes for your application.
import 'package:flutter/material.dart';
import 'ui/post/post_list.dart';
import 'ui/login/login.dart';
import 'ui/splash/splash.dart';
class Routes {
Routes._();
//static variables
static const String splash = '/splash';
static const String login = '/login';
static const String home = '/post';
static final routes = <String, WidgetBuilder>{
splash: (BuildContext context) => SplashScreen(),
login: (BuildContext context) => LoginScreen(),
home: (BuildContext context) => HomeScreen(),
};
}
This is the starting point of the application. All the application level configurations are defined in this file i.e, theme, routes, title, orientation etc.
import 'package:boilerplate/routes.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'constants/app_theme.dart';
import 'constants/strings.dart';
import 'ui/splash/splash.dart';
void main() {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]).then((_) {
runApp(MyApp());
});
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: Strings.appName,
theme: themeData,
routes: Routes.routes,
home: SplashScreen(),
);
}
}
Checkout wiki for more info
I will be happy to answer any questions that you may have on this approach, and if you want to lend a hand with the boilerplate then please feel free to submit an issue and/or pull request 🙂
Again to note, this is example can appear as over-architectured for what it is - but it is an example only. If you liked my work, don’t forget to ⭐ star the repo to show your support.