当前位置:网站首页>跟我学企业级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!;
}
}
边栏推荐
- 架构实战营 - 第 6 期 毕业总结
- LeetCode1491. Average value of wages after removing the minimum wage and the maximum wage
- Chinese translation of Tagore's floating birds (1~10)
- [combinatorics] combinatorial identities (review of eight combinatorial identities | product of combinatorial identities 1 | proof | use scenario | general method for finding combinatorial numbers)
- How can technology managers quickly improve leadership?
- Redis high availability and persistence
- “用Android复刻Apple产品UI”(3)—优雅的数据统计图表
- Project -- high concurrency memory pool
- Golang 装饰器模式以及在NSQ中的使用
- Approval process design
猜你喜欢

Microservice - Nacos registration center and configuration center

Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package

TCP congestion control details | 3 design space
![[statement] about searching sogk1997 and finding many web crawler results](/img/1a/8ed3ca0030ea227adcd95e8b306aca.png)
[statement] about searching sogk1997 and finding many web crawler results

NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon

Getting started with Message Oriented Middleware

2022年Q2加密市场投融资报告:GameFi成为投资关键词
![[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix](/img/d6/3c21c25f1c750f17aeb871124e80f4.png)
[proteus simulation] 74hc595+74ls154 drive display 16x16 dot matrix

From the 18th line to the first line, the new story of the network security industry

Distributed task scheduling XXL job
随机推荐
Go语言自学系列 | golang中的if else语句
Create gradle project
How to use AAB to APK and APK to AAB of Google play apps on the shelves
嵌入式开发:避免开源软件的7个理由
关于网页中的文本选择以及统计选中文本长度
Pyinstaller is not an internal or external command, nor is it a runnable program or batch file
MongoDB 的安装和基本操作
1287. Elements that appear more than 25% in an ordered array
切入点表达式
Stm32f103c8t6 firmware library lighting
探索Cassandra的去中心化分布式架构
《天天数学》连载56:二月二十五日
Embedded development: seven reasons to avoid open source software
Mb10m-asemi rectifier bridge mb10m
远程办公之大家一同实现合作编辑资料和开发文档 | 社区征文
Project -- high concurrency memory pool
Semi supervised learning
Explore Cassandra's decentralized distributed architecture
Detailed explanation of four modes of distributed transaction (Seata)
Go language self-study series | if else if statement in golang