bloc_event_gen 0.1.3

  • Readme
  • Changelog
  • Installing
  • 49

Getting Started #

Add the packages to your pubspec.yaml file:

dependencies:
  bloc_event_gen: ^[latest version]

dev_dependencies:
  build_runner: ^1.5.2 # Also depend on build_runner if you aren't already.
  bloc_event_generator: ^[latest version]

Annotate your BLoC class with BlocEvents:

@BlocEvents({
  'NavigateToAwesomePage': {},
  'ShowSnackBar': {
    'message': String,
    'duration': Duration,
  },
})
class HomeBloc // ...

Specify the part file for the generator code:

part 'your_bloc_file_name.g.dart';

Run the build:

$ flutter pub run build_runner build

...or have it watch for changes:

$ flutter pub run build_runner watch

The output will be the following code in the your_bloc_file_name.g.dart file:

class NavigateToAwesomePage extends BlocEvent {
  NavigateToAwesomePage();
}

class ShowSnackBar extends BlocEvent {
  final String message;
  final Duration duration;
  ShowSnackBar(this.message, this.duration);
}

See the example project for a working example.

0.1.0 #

  • Initial version

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

Format lib/src/bloc_event.dart.

Run dartfmt to format lib/src/bloc_event.dart.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://github.com/xiprox/bloc_events_gen was unreachable.

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 bloc_event_gen.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 >=2.2.0 <3.0.0