tetris_blocs 1.0.0

Flutter Android iOS web

Blocs for Flutter made easy. A light-weight, flexible, event-based implementation of the BLoC Pattern.

Tetris #

BLoCs for Flutter made easy.

Build Status

Goals #

Simplicity #

Write the Code you need with as minimal Boilerplate as possible

RxDart Syntax #

Feel at Home

Flexibility #

Be usefull everywhere, even in now-unknown places

Chaining #

Yo dawg, I heard you like Blocs, so I put some Blocs in your Blocs, so now you can play Tetris while playing Tetris



TetrisEvent(action, payload) #

An Event happening in your App, originating by UI or somewhere else. TetrisEvents are fully described by

  • String action The action you expect to happen
  • String type Optional Type of event
  • dynamic payload Any type of Object you want to process

TetrisBloc #

A TetrisBloc is an asynchronous Event Processor. It handles events sourced through


in its

Stream<TetrisEvent> processEvent(TetrisEvent event)

function and yields a (new) event as a result.

TetrisProvider #

TetrisProvicer is a DI Container that provides instances of your TetrisBloc's to Widgets in your App.
A Provider can hold multiple BLoCs and you can have multiple Providers in your App. To retrieve a BLoC from the Provider call

var bloc = TetrisProvider.of<MyBloc>(context) 

TetrisBuilder #

TetrisBuilder is similar to StreamBuilder in that it will rebuild your Widgets on incoming TetrisEvents A Single Builder can receive Events from multiple BLoCs. It has a withFilter Constructor that allows you to drop Events that are not of interest.

      blocs: [myFirstBloc, mySecondBloc],
      builder: (BuildContext context, TetrisEvent event) { return Text(event.action) },
      filter: (TetrisEvent event){ return event.action == "accept"; }

Examples #

Loading a List #

With Simplicity in Mind, loading a List is down to two lines of code. To Trigger the Action:


And the full implementation of the Bloc is this:

 class MyTetrisBloc extends TetrisBloc {
    Stream<TetrisEvent> processEvent(TetrisEvent event) async* {
      yield TetrisEvent.withPayload("loadList",[1,3,5,7]);

Example Project

The classic "Button Clicker" Example is here


  • @dividebyzero :shipit:
  • Your name here ?
pub points

Blocs for Flutter made easy. A light-weight, flexible, event-based implementation of the BLoC Pattern.

Repository (GitHub)
View/report issues


API reference




Apache 2.0 (LICENSE)


flutter, rxdart


Packages that depend on tetris_blocs