bloc_annotations 0.4.0

  • Example
  • Installing
  • Versions
  • 78

bloc_annotations #

Installation #

  bloc_annotations: <latest_version>

Import Requirements #

bloc_annotations uses the @required where BLoCParamater is used. package:flutter/material.dart needs to be imported when this is used as the generated part file cannot have import statements. Any services that are used also need to be imported.

Class Member Requirements #

All the members of your BLoC class that have annotations must be public as the generated code uses them. Members without annotations can still be used in @BLoCMapper methods as the member is called and not copied to the output class. @BLoCValues initial data will not be copied to the BLoC class and will have no effect on the initial data.

Different Controllers #

Using StreamController isn't required so rxdarts subjects such as BehaviourSubject can be used as shown in the example.

Output Class #

The output class can be seen in the generated .bloc.dart file. The BLoC class defines the inputs and outputs of the bloc and calls your @BLoCMappers when somthing is added to the input streams and adds the output to the output streams. The BLoC class will also create, initialize and dispose of any services you require.

Services #

Services are automated parts of a BLoC. They can be inputs, outputs, consume the entire BLoC, be a mapper or be triggered manually. You can find all the available services here.

Example #

An extensive example can be found in the root example/ directory.

0.4.0 #

  • Change name from flutter_bloc_annotations to bloc_annotations

0.3.0 #

  • Moved annotation inputs to Type from String where possible
  • Added BLoCTemplate and Service abstract classes for type safety

0.2.6 #

  • Add MapperService, AsyncMapperService, RequireMapperService and RequireAsyncMapperService

0.2.5 #

  • Currect trigger types to Future
  • Make mappers optionally async

0.2.4 #

  • Add TriggeredService

0.2.3 #

  • Allow mappers to return null to not add anything to the output

0.2.2 #

  • Added paramaters that can be passed to the BLoC and are accessible to BLoC services

0.2.1 #

  • Make requiring a service require the service type
  • Add BLoCService service that takes an entire BLoC instead of a Stream or Sink

0.2.0 #

  • Make mappers async

0.1.9 #

  • Make template value the only current value stored

0.1.8 #

  • Moved value updater before calling mappers
  • Updating latest values on template

0.1.7 #

  • OutputService automatic listener
  • OutputService automatic subscription disposer

0.1.6 #

  • Remove current data from mappers

0.1.5 #

  • Updated service documentation

0.1.4 #

  • Changed Service to InputService and added OutputService
  • Corrected name in README

0.1.3 #

  • Fix README discrepencies

0.1.2 #

  • Added documentation comments

0.1.1 #

  • Fix library name
  • Add example
  • Format code

0.1.0 #

  • Initial public release


/// An extensive example is available at

Use this package as a library

1. Depend on it

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

  bloc_annotations: ^0.4.0

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_annotations/bloc_annotations.dart';
Version Uploaded Documentation Archive
0.6.0 May 28, 2019 Go to the documentation of bloc_annotations 0.6.0 Download bloc_annotations 0.6.0 archive
0.5.1 May 20, 2019 Go to the documentation of bloc_annotations 0.5.1 Download bloc_annotations 0.5.1 archive
0.5.0 Mar 27, 2019 Go to the documentation of bloc_annotations 0.5.0 Download bloc_annotations 0.5.0 archive
0.4.0 Jan 1, 2019 Go to the documentation of bloc_annotations 0.4.0 Download bloc_annotations 0.4.0 archive
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 May 30, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.17


Detected platforms: Flutter, web, other

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


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
meta ^1.1.6 1.1.7