eventBus for Flutter & Dart
RomeBus
Eventbus框架,适用于Flutter,Dart项目
Architecture
Pub
dependencies:
rome_bus: ^0.0.2
Usage with 3 step
1. Create an Event Object
//event object
class CommonEvent {
final int count;
CommonEvent(this.count);
}
2. Register an Event
String eventRegisterText ='';
@override
void initState() {
super.initState();
//just control event object
RomeBus.getBus().register<CommonEvent>((event) {
setState(() {
eventRegisterText = 'register event ${event.count}';
});
});
}
3. Send an Event
RomeBus.getBus().send(CommonEvent(100));
Using Vip Event
Sometimes you only need to listen to the event once, you can use VipEvent.
see example vip_page .