events2 0.1.3

dart-events #

Event emitter for dart2.

Usage #


import 'package:events2/events2.dart';

main() {
  EventEmitter event_emitter = new EventEmitter();

  event_emitter.on('event1', (arg0, String arg1, int arg2, arg3) {
    print('arg0 = ' + arg0 + ', arg1 = ' + arg1 + ', arg2 = ' + arg2.toString() + ', arg3 = ' + arg3.toString());
  });

  event_emitter.once('event2', () {
    print('event2 ');
  });
  
  event_emitter.emit('event1', 'a', 'b', null);
  event_emitter.emit('event2');
}

Changelog #


[0.1.3] - 2019.03.22

  • Fixed a crash when handler list is empty.

[0.1.2] - 2019.03.22

  • Add remove method.

[0.1.1] - 2019.01.24

  • Change filename events.dart => events2.dart.

[0.1.0] - 2019.01.14

  • Initial release.

Use this package as a library

1. Depend on it

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


dependencies:
  events2: ^0.1.3

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:events2/events2.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
46
Health:
Code health derived from static analysis. [more]
86
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

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

Analysis of lib/src/event_emitter.dart reported 31 hints, including:

line 4 col 3: Prefer using /// for doc comments.

line 9 col 3: Prefer using /// for doc comments.

line 14 col 3: Prefer using /// for doc comments.

line 29 col 16: Avoid using null in if null operators.

line 32 col 16: Avoid using null in if null operators.

Format lib/events2.dart.

Run dartfmt to format lib/events2.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and events2.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK <3.0.0

Admin