Last updated:
0 purchases
fast module
Features #
flutter 组件化容器
Getting started #
fast_moudle_manager 负责注册模块、注册路由、模块之间通讯
fast_module_protocol 需要模块来实现, 提供路由以及接受消息
Usage #
main函数配置
// 1. 首先注册模块
FastModuleManager.registerBuilder((manager) {
manager.register(ModuleA());
});
// 2. 动态路由 任选一种
GetMaterialApp(onGenerateRoute:
FastModuleManager.instance().onGenerateRoute(settings));
// 2. 静态路由 任选一种
GetMaterialApp(getPages: FastModuleManager.instance().pages());
copied to clipboard
子模块配置
<!--
lib
src
业务代码
ykq_ble_modules.dart
main.dart
-->
// ykq_ble_modules 实现
class ModuleA extends FastModuleProtocol {
// 提供子模块路由
@override
GetPageRoute? onGenerateRoute(RouteSettings settings) {
switch (settings.name) {
case: 'module/A'
return GetPageRoute(settings:settings,page:()=>A(),bindings:ABingdings());
default:
return null;
}
}
// 接收其他模块发送的消息
@override
onReceivedMessage({String evnetName = '', arguments}) {
if (evnetName == 'msg') {
}
}
// 子模块的初始化任务
@override
void init() {
TXSDK.init();
JPPush.init();
...
}
// ... app生命周期监听 等等
}
copied to clipboard
模块间通信
final 返回值 = FastModuleManager.instance().dispatch(模块名, 事件名, 参数);
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.