minibus 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

minibus #

A library for a minimal synchronous event bus.

Basic Usage #

A simple usage example:

import 'package:minibus/minibus.dart';
String EVENT = "myevent";

main() {
  MiniBus bus1 = new MiniBus();
  bus1.subscribe(EVENT, (){print('Hello World!')});;

Features and bugs #

Please file feature requests and bugs.

Run tests with:

  • pub run test

Check source code formatting:

  • dartfmt -n .

Changelog #

1.0.0 #

  • Refactors and move version to 1.

0.0.5 #

  • Updates for Dart 2.

0.0.4 #

  • Minor refactoring and SDK constraint changed.

0.0.3 #

  • Update to prepare for Dart 2.0.
  • Documentation updated - details and example.

0.0.2 #

  • Added (optionally) events with data providers.

0.0.1 #

  • Initial version.


// Copyright (c) 2017-2018, daftspaniel. 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:minibus/minibus.dart';

const EVENT = "Greeting";
const ANOTHER_EVENT = "Goodbye";

void hello() {

void hi() {

void bye() {

main() {
  print('\n * Event with single listener.\n');
  var bus1 = new MiniBus();
  bus1.subscribe(EVENT, hi);;

  print('\n * Event with multiple listeners.\n');
  var bus2 = new MiniBus();
  bus2.subscribe(EVENT, hi);
  bus2.subscribe(EVENT, hello);
  bus2.subscribe(ANOTHER_EVENT, bye);;

  print('\n * See what is connected:\n');;;

  print('\n * Get some data with and event:\n');
  var bus3 = new MiniBus();
  int eventValue;
  int provider() {
    return 1234;

  void handler(Function dataProvider) {
    eventValue = dataProvider();

  bus3.subscribe("Test", handler);"Test", provider);
  print('   event returned ${eventValue}');;

Use this package as a library

1. Depend on it

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

  minibus: ^1.0.1

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:minibus/minibus.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 Nov 22, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:minibus/minibus.dart.

Health suggestions

Fix lib/src/minibus_base.dart. (-1.49 points)

Analysis of lib/src/minibus_base.dart reported 3 hints:

line 5 col 26: Unnecessary new keyword.

line 27 col 21: Unnecessary new keyword.

line 34 col 28: Don't explicitly initialize variables to null.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
test ^1.3.0