bloc_helpers 0.1.1

  • Installing
  • Versions
  • 85

Dart Bloc Pattern helper

What is Bloc pattern ?


This package contain helper class and common Bloc Pattern

  • Bloc (base to implement Bloc pattern)
  • RequestBloc
  • CachedRequestBloc
  • SelectorBloc

Bloc class

The bloc class is a simple class that provide dispose function and a disposed boolean

abstract class Bloc {
  bool _disposed = false;

  bool get disposed => _disposed;

  void dispose() {
    _disposed = true;

Request bloc

RequestBloc help to implement async call, it provides following stream ans sink.

Sink<Request> requestSink

Stream<bool> onLoading

Stream<Request> onRequest

Stream<Response> onResponse

CachedRequestBloc add the ability to cache response, to avoid multiple call when request does not change, it provides following stream and sink.

Stream<Response> cachedResponse

Sink<Response> invalidateCacheSink

Sink<Response> updateCachedResponseSink


import 'package:bloc_helpers/bloc_helpers.dart';
import 'package:meta/meta.dart';

class MyRequestBloc extends RequestBloc<MyRequest, MyResponse> {
  Future<MyResponse> request(MyRequest input) async {
    // TODO: implement request
    return MyResponse();


See example

Selector bloc

Selector bloc help implementing a simple selection behavior

final selector = SelectorBloc<String>();

  selector.selected.listen((selected) => print(selected));


  selector.selectAllSink.add(['foo', 'bar']);


This repository is open to Pull Request and new idea :)


  • fix selector


  • Observable instead of Stream
  • use ValueObservable
  • dispose function is now async


  • addd disposed check before addError


  • cleanup abd better README


  • protected request method


  • fix cached response sink


  • add onRequest stream


  • first version

Use this package as a library

1. Depend on it

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

  bloc_helpers: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:bloc_helpers/bloc_helpers.dart';
Version Uploaded Documentation Archive
0.1.1 Dec 4, 2018 Go to the documentation of bloc_helpers 0.1.1 Download bloc_helpers 0.1.1 archive
0.1.0 Nov 30, 2018 Go to the documentation of bloc_helpers 0.1.0 Download bloc_helpers 0.1.0 archive
0.0.6 Nov 19, 2018 Go to the documentation of bloc_helpers 0.0.6 Download bloc_helpers 0.0.6 archive
0.0.5+1 Oct 8, 2018 Go to the documentation of bloc_helpers 0.0.5+1 Download bloc_helpers 0.0.5+1 archive
0.0.5 Sep 18, 2018 Go to the documentation of bloc_helpers 0.0.5 Download bloc_helpers 0.0.5 archive
0.0.4 Sep 3, 2018 Go to the documentation of bloc_helpers 0.0.4 Download bloc_helpers 0.0.4 archive
0.0.3 Aug 28, 2018 Go to the documentation of bloc_helpers 0.0.3 Download bloc_helpers 0.0.3 archive
0.0.2 Aug 27, 2018 Go to the documentation of bloc_helpers 0.0.2 Download bloc_helpers 0.0.2 archive
0.0.1 Aug 7, 2018 Go to the documentation of bloc_helpers 0.0.1 Download bloc_helpers 0.0.1 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 Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7


Detected platforms: Flutter, web, other

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

Health suggestions

Format lib/src/request.dart.

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

Maintenance suggestions

Maintain an example.

None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use bloc_helpers.dart. Packages with multiple examples should use example/


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.23.0 <3.0.0
meta ^1.1.0 1.1.6
rxdart >=0.17.0 <1.0.0 0.19.0