eventBus for Flutter & Dart

RomeBus

Logo

Eventbus框架,适用于Flutter,Dart项目

Architecture

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 .

Screen

architecture

Github

 

posted @ 2020-12-03 15:31  狂奔的小狮子  阅读(270)  评论(0编辑  收藏  举报