evento 1.0.0 copy "evento: ^1.0.0" to clipboard
evento: ^1.0.0 copied to clipboard

outdated

Dart/Flutter communication package based on events

Evento #

A super simple implementation of the pub-sub pattern in the format of a mixin.

API #

For the StatelessWidget the EventoStatelessWidget mixin only adds the dispatch method while for the StatefulWidget's state Evento adds on and `dispatch.

  • dispatch(String type, [data]) - type is the name of the event and data is an optional payload.
  • on(String type, Function listener) - type is the name of the event and listener is a function that accepts object of type EEvent. It has type (again a string) and data which is the payload (if any) used in dispatched.

Example #

import 'package:evento/evento.dart';

class A extends StatelessWidget with EventoStatelessWidget {
  Widget build(context) {
    return MaterialButton(onPressed: () {
      dispatch('foo', 'world');
    });
  }
}

class B extends StatefulWidget {
  State createState() => _B();
}

class _B extends State<B> with Evento {
  String value = 'Hey';
  void initState() {
    on('foo', (EEvent event) {
      setState(() {
        value = 'Hello ${event.data}';
      });
    });
  }

  Widget build(context) {
    return Text(value);
  }
}
0
likes
0
points
64
downloads

Publisher

unverified uploader

Weekly Downloads

Dart/Flutter communication package based on events

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on evento