当前位置:网站首页>跟我学企业级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!;
}
}
边栏推荐
- Function introduction of JMeter thread group
- 无心剑中译泰戈尔《漂鸟集(1~10)》
- Is it safe to open an account with tongdaxin?
- The mixlab editing team is recruiting teammates~~
- 面试官:JVM如何分配和回收堆外内存
- 近视:摘镜or配镜?这些问题必须先了解清楚
- [statement] about searching sogk1997 and finding many web crawler results
- 如何在本机搭建SVN服务器
- Record a jar package conflict resolution process
- Qt插件之自定义插件构建和使用
猜你喜欢
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
From "zero sum game" to "positive sum game", PAAS triggered the third wave of cloud computing
MB10M-ASEMI整流桥MB10M
【Proteus仿真】74HC595+74LS154驱动显示16X16点阵
突破100万,剑指200万!
Three dimensional reconstruction of deep learning
From the 18th line to the first line, the new story of the network security industry
Getting started with Message Oriented Middleware
请做好3年内随时失业的准备?
Explore Cassandra's decentralized distributed architecture
随机推荐
Batch files: list all files in a directory with relative paths - batch files: list all files in a directory with relative paths
Project -- high concurrency memory pool
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix
pycharm错Error updating package list: connect timed out
请求头不同国家和语言的表示
TCP congestion control details | 3 design space
[web security] - [SQL injection] - error detection injection
相同切入点的抽取
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Colab works with Google cloud disk
Page dynamics [2]keyframes
Getting started with Message Oriented Middleware
Stm32f103c8t6 firmware library lighting
Effect of ARP package on FTP dump under vxworks-6.6 system
Go language self-study series | if else if statement in golang
记一次jar包冲突解决过程
Go language self-study series | golang switch statement
Persisting in output requires continuous learning
嵌入式开发:避免开源软件的7个理由
Salary 3000, monthly income 40000 by "video editing": people who can make money never rely on hard work!