tetris_blocs 1.0.0

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

Contributors #

  • @dividebyzero :shipit:
  • Your name here ?

[1.0.0] - 12. April 2019

  • Initial Release provides all base funtionality of BLoCs

[1.0.1] - 25. April 2019

  • Maintenance Release


tetris_example #

This project uses the classic Flutter Starter to demonstrate the Tetris BLoC Library

Getting Started #

All code is documented in main.dart

To run it, simply clone the repository and call flutter run

Use this package as a library

1. Depend on it

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

  tetris_blocs: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support 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:tetris_blocs/tetris_blocs.dart';
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 Feb 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Fix lib/core/tetris_provider.dart. (-1.49 points)

Analysis of lib/core/tetris_provider.dart reported 3 hints:

line 16 col 10: 'ancestorInheritedElementForWidgetOfExactType' is deprecated and shouldn't be used. Use getElementForInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1..

line 29 col 5: 'TypeMatcher' is deprecated and shouldn't be used. TypeMatcher has been deprecated because it is no longer used in framework(only in deprecated methods). This feature was deprecated after v1.12.1..

line 29 col 34: 'TypeMatcher' is deprecated and shouldn't be used. TypeMatcher has been deprecated because it is no longer used in framework(only in deprecated methods). This feature was deprecated after v1.12.1..

Fix lib/core/tetris_bloc.dart. (-0.50 points)

Analysis of lib/core/tetris_bloc.dart reported 1 hint:

line 18 col 3: The class 'Stream' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix lib/core/tetris_builder.dart. (-0.50 points)

Analysis of lib/core/tetris_builder.dart reported 1 hint:

line 64 col 23: Cancel instances of dart.async.StreamSubscription.

Format lib/core/tetris_event.dart.

Run flutter format to format lib/core/tetris_event.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (rxdart).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
rxdart ^0.21.0 0.21.0 0.23.1
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies