当前位置:网站首页>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!;
}
}
边栏推荐
- 用通达信炒股开户安全吗?
- App mobile terminal test [3] ADB command
- 面试之 top k问题
- Interviewer: how does the JVM allocate and recycle off heap memory
- 手机注册股票开户安全吗 开户需要钱吗
- 在ntpdate同步时间的时候出现“the NTP socket is in use, exiting”
- Client does not support authentication protocol requested by server; consider upgrading MySQL client
- Golang 匿名函数使用
- How to thicken the brush in the graphical interface
- Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
猜你喜欢
[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)
[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
The difference between calling by value and simulating calling by reference
How to thicken the brush in the graphical interface
From the 18th line to the first line, the new story of the network security industry
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
Redis installation under windows and Linux systems
ThreeJS 第二篇:顶点概念、几何体结构
Low level version of drawing interface (explain each step in detail)
【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事
随机推荐
Mixlab编辑团队招募队友啦~~
架构实战营 - 第 6 期 毕业总结
特征多项式与常系数齐次线性递推
Client does not support authentication protocol requested by server; consider upgrading MySQL client
First!! Is lancet hungry? Official documents
初试scikit-learn库
Caching mechanism of Hibernate / session level caching mechanism
关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM
Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
Explore Cassandra's decentralized distributed architecture
NSQ源码安装运行过程
[solved] access denied for user 'root' @ 'localhost' (using password: yes)
远程文件包含实操
June to - -------
Deep understanding of grouping sets statements in SQL
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)
Golang 装饰器模式以及在NSQ中的使用
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
Expression of request header in different countries and languages
From the 18th line to the first line, the new story of the network security industry