module_bridge 0.0.1 copy "module_bridge: ^0.0.1" to clipboard
module_bridge: ^0.0.1 copied to clipboard

Dart modular development, event communication library. Dart模块化开发,事件通信库。

中文文档 #

Dart modular development event communication library. #

Step1 #

Install FlutterModuleBridge plugin.

Step2 #

Create a communication template in the module /lib directory

import 'package:module_bridge/module_bridge.dart';

class UserBridge with Bridge {

   @Url(url: '/user/getUserId', desc: 'Get UserId')
   R getUserId() {
     return R.ok(data: 1234);
   }

   @Url(url: '/user/getUserName', desc: 'Get user name')
   Future<R> getUserName() async {
     return R.ok(data: 'azhon');
   }
}

⚠️Notice

  • A dart file can only have one class
  • The class must be with Bridge
  • The method must be annotated with @Url
  • The return value of the method must be R or Future<R> type

Step3 #

1.Use FlutterModuleBridge plugin generate class

2.Register events when initializing the modules

BridgeManager.instance.register(UserModuleBridge().bridges);

Step4 #

In any module communicate through the following code

var r = await BridgeManager.instance.get('/user/getUserId');
1
likes
140
points
68
downloads

Publisher

unverified uploader

Weekly Downloads

Dart modular development, event communication library. Dart模块化开发,事件通信库。

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on module_bridge