eventify 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

EventEmitter #

EventEmitter for dart. This can be used in any application to register for events and get notified once it is fired.

This library provide mechanism to register for event notifications with emitter or publisher and get notified in the event of an event.

One main advantage of the mehanism is that, it support context from where the subscriber is listening. The context could be any additional data the subscriber is interested in.

Another feature this has is the ability to receive sender information, which could be handy if the subscriber wish to know about the publisher.

Example #

    void performAddition(){


    EventCallback cb = (ev, cont) {
        if (null != ev) {
          switch (ev.eventName) {
            case "add":

    EventEmitter emitter = new EventEmitter();
    Listener listener = emitter.on("add", this , cb);


As shown in the above example, it is easy to register for events and get notified once it is triggered.

0.1.3 #

  • Performance optimization - Observed that in real-time applications, removing event handlers were taking lots of time. Same observed with adding handlers also.
  • Modified code to use Set, instead of list to provide faster performance.
  • Removed unwanted checks while adding handlers.

0.1.3 #

  • Addressed health and maintenance suggestions.

0.1.2 #

  • Added additional examples.

0.1.1 #

  • Removing event registration in the callback caused exception. Addressed the issue by creating a sublist and triggering callback from there.

0.1.0 #

  • Added example.dart

0.0.9 #

  • Added CHANGELOG.md

0.0.8 #

First reviewed version.


// Copyright (c) 2019, iMeshAcademy authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:eventify/eventify.dart';
import 'dart:async';

Future parseStores(Object config) {
  return new Future(() {
    print("Inside the future.");
    if (null != config) {
      Map<String, Map<String, dynamic>> storeConfigs =
          config as Map<String, Map<String, dynamic>>;
      storeConfigs.forEach((str, val) {
        val.forEach((store, details) {

void main() {
  Map<String, dynamic> data = {
    "stores": {
      "store1": {"generator": 1, "config": {}},
      "store2": {"generator": 2, "config": {}}
    "models": {
      "model1": {"generator": 1, "name": "modelel1", "linkedStore": "store1"}

  Function parseModels = (config) {};

  data.forEach((key, val) {
    switch (key) {
      case "stores":
        parseStores(val).then((res) {
          print("Store is parsed");
      case "models":

  print("After the loop!!");

  EventEmitter emitter = new EventEmitter();
  emitter.on("test", null, (ev, context) {
    print("${ev.eventName} - ${ev.eventData}");

  emitter.emit("test", null, "Test data");

  int count = 0;

  ExtendedEmitter timer = new ExtendedEmitter();
  timer.on("timer", null, (ev, context) {
    print("Received ${ev.eventName} event from emitter!");
    if (count == 10) {
      Timer t = ev.eventData as Timer;


class ExtendedEmitter extends EventEmitter {
  void timerCallback(Timer timer) {
    emit("timer", this, timer);

  void doSomeOperation() {
    Timer.periodic(Duration(seconds: 1), timerCallback);

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  eventify: ^0.1.4

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:eventify/eventify.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Health suggestions

Fix lib/src/event_emitter.dart. (-1.99 points)

Analysis of lib/src/event_emitter.dart reported 4 hints:

line 28 col 50: Unnecessary new keyword.

line 32 col 18: Unnecessary new keyword.

line 34 col 13: Use isEmpty instead of length

line 88 col 18: Unnecessary new keyword.

Maintenance suggestions

Package is getting outdated. (-38.90 points)

The package was last published 72 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.0.0