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 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.


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