当前位置:网站首页>跟我学企业级flutter项目:简化框架demo参考
跟我学企业级flutter项目:简化框架demo参考
2022-07-03 16:13:00 【二蛋和他的大花】
前言
最近很多人在问我,没有一个不错的demo,不会如何做单工程模式,如何封装网络请求,如何去做网络持久化。那么今天我将demo分享出来。现阶段还无法把我构建的flutter快速开发框架开源出来。暂时用简化demo来展示。
相关文章:
跟我学企业级flutter项目:flutter模块化,单工程架构模式构思与实践
跟我学企业级flutter项目:如何用dio封装一套企业级可扩展高效的网络层
跟我学企业级flutter项目:dio网络框架增加公共请求参数&header
demo地址:
https://github.com/smartbackme/myflutter
为了大家更清楚的使用,我将对目录结构进行说明:
目录结构

以模块一来说明

模块一启动配置:
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());
}
公共模块说明

主工程启动说明
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;
// 路由分配管理
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();
}
}
//启动初始化
void main() async {
MyFlutterBinding.ensureInitialized();
KgDensity.initKgDensity(designWidth : 375);
await SpSotre.instance.init();
ULogManager.init();
Application.init(AppInit(MyCommentConfiger()));
runApp(const MyApp());
}
//WidgetsFlutterBinding 配置
class MyFlutterBinding extends WidgetsFlutterBinding with KgFlutterBinding {
static WidgetsBinding ensureInitialized() {
if (WidgetsBinding.instance == null) MyFlutterBinding();
return WidgetsBinding.instance!;
}
}
边栏推荐
- 2022年Q2加密市场投融资报告:GameFi成为投资关键词
- 【OpenCV 例程200篇】217. 鼠标交互获取多边形区域(ROI)
- June to - -------
- Deep understanding of grouping sets statements in SQL
- 请做好3年内随时失业的准备?
- Low level version of drawing interface (explain each step in detail)
- Thinking about telecommuting under the background of normalization of epidemic | community essay solicitation
- ThreeJS 第二篇:顶点概念、几何体结构
- 关于网页中的文本选择以及统计选中文本长度
- [combinatorics] combinatorial identities (review of eight combinatorial identities | product of combinatorial identities 1 | proof | use scenario | general method for finding combinatorial numbers)
猜你喜欢

Initial test of scikit learn Library
![[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix](/img/d6/3c21c25f1c750f17aeb871124e80f4.png)
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix

Mb10m-asemi rectifier bridge mb10m

突破100万,剑指200万!

How can technology managers quickly improve leadership?

Shell script import and export data

How to use AAB to APK and APK to AAB of Google play apps on the shelves

Cocos Creator 2.x 自动打包(构建 + 编译)

The difference between calling by value and simulating calling by reference

The mixlab editing team is recruiting teammates~~
随机推荐
嵌入式开发:避免开源软件的7个理由
请做好3年内随时失业的准备?
Microservice sentinel flow control degradation
[combinatorics] summary of combinatorial identities (eleven combinatorial identities | proof methods of combinatorial identities | summation methods)*
Persisting in output requires continuous learning
Golang 匿名函数使用
在ntpdate同步时间的时候出现“the NTP socket is in use, exiting”
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Colab works with Google cloud disk
Salary 3000, monthly income 40000 by "video editing": people who can make money never rely on hard work!
高等数学(第七版)同济大学 习题2-1 个人解答
Microservice API gateway
疫情常态化大背景下,关于远程办公的思考|社区征文
MongoDB 的安装和基本操作
Myopia: take off or match glasses? These problems must be understood clearly first
【OpenCV 例程200篇】217. 鼠标交互获取多边形区域(ROI)
LeetCode1491. Average value of wages after removing the minimum wage and the maximum wage
[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)
Project -- high concurrency memory pool
Record a jar package conflict resolution process