当前位置:网站首页>Learn from me about the enterprise flutter project: simplified framework demo reference
Learn from me about the enterprise flutter project: simplified framework demo reference
2022-07-03 16:25:00 【Erdan and his big flower】
Preface
Recently, many people are asking me , None of them is good demo, How to do single engineering mode , How to encapsulate network requests , How to do network persistence . So today I will demo Share it out . At this stage, I can't build flutter The rapid development framework is open source . Temporarily simplify demo To show .
Related articles :
Learn from me about enterprise flutter project :flutter modularization , Conception and practice of single project architecture mode
demo Address :
https://github.com/smartbackme/myflutter
For everyone to use more clearly , I will explain the directory structure :
Directory structure

Explain with a module

Module 1 startup configuration :
class MyConfiger extends ICommentConfiger{
@override
Widget getRouter(RouteSettings settings) {
var router = RouterPage.getRouter(settings);
if(router!=null){
return router;
}
return const NullRouter();
}
}
void main() {
Application.init(AppInit(MyConfiger()));
runApp(const MyApp());
}
Common module description

Main project startup instructions
import 'package:commonmodule/commonmodule.dart';
import 'package:commonmodule/config.dart';
import 'package:flutter/material.dart';
import 'package:commonmodule/router_name.dart' as common;
import 'package:kg_density/kg_density.dart';
import 'package:myflutter/page/home.dart';
import 'package:onemodule/router_page.dart' as onemodule;
import 'package:twomodule/router_page.dart' as twomodule;
// Routing assignment management
class MyCommentConfiger extends ICommentConfiger{
@override
Widget getRouter(RouteSettings settings) {
if(settings.name == common.RouterName.home){
return const HomePage();
}
var teachertRouter = onemodule.RouterPage.getRouter(settings);
if(teachertRouter!=null){
return teachertRouter;
}
var clientRouter = twomodule.RouterPage.getRouter(settings);
if(clientRouter!=null){
return clientRouter;
}
return const NullRouter();
}
}
// Start initialization
void main() async {
MyFlutterBinding.ensureInitialized();
KgDensity.initKgDensity(designWidth : 375);
await SpSotre.instance.init();
ULogManager.init();
Application.init(AppInit(MyCommentConfiger()));
runApp(const MyApp());
}
//WidgetsFlutterBinding To configure
class MyFlutterBinding extends WidgetsFlutterBinding with KgFlutterBinding {
static WidgetsBinding ensureInitialized() {
if (WidgetsBinding.instance == null) MyFlutterBinding();
return WidgetsBinding.instance!;
}
}
边栏推荐
- Record a jar package conflict resolution process
- PHP secondary domain name session sharing scheme
- MongoDB 的安装和基本操作
- How to initialize views when loading through storyboards- How is view initialized when loaded via a storyboard?
- Threejs Part 2: vertex concept, geometry structure
- 于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
- Cocos Creator 2. X automatic packaging (build + compile)
- 用通达信炒股开户安全吗?
- Uploads labs range (with source code analysis) (under update)
- The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)
猜你喜欢

Cocos Creator 2. X automatic packaging (build + compile)

嵌入式开发:避免开源软件的7个理由

【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事

Mysql 单表字段重复数据取最新一条sql语句

关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM

【Proteus仿真】74HC595+74LS154驱动显示16X16点阵

面试官:JVM如何分配和回收堆外内存

为抵制 7-Zip,列出 “三宗罪” ?网友:“第3个才是重点吧?”

Stm32f103c8t6 firmware library lighting

记一次jar包冲突解决过程
随机推荐
The difference between calling by value and simulating calling by reference
Batch files: list all files in a directory with relative paths - batch files: list all files in a directory with relative paths
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
程序猿如何快速成长
面试之 top k问题
[web security] - [SQL injection] - error detection injection
Interviewer: how does the JVM allocate and recycle off heap memory
Characteristic polynomial and constant coefficient homogeneous linear recurrence
[combinatorics] non descending path problem (outline of non descending path problem | basic model of non descending path problem | non descending path problem expansion model 1 non origin starting poi
六月 致 -.-- -..- -
Mixlab编辑团队招募队友啦~~
PHP二级域名session共享方案
Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
Explore Netease's large-scale automated testing solutions see here see here
【LeetCode】94. Middle order traversal of binary tree
Threejs Part 2: vertex concept, geometry structure
Unity project optimization case 1
Client does not support authentication protocol requested by server; consider upgrading MySQL client
Qt插件之自定义插件构建和使用
Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day