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

(soon)

API #

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

MyTetrisBloc.dispatch(TetrisEvent.withAction(action:"MyAction")); 

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.

TetrisBuilder.withFilter(
      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:

  TetrisProvider.of<MyTetrisBloc>(context).dispatch(TetrisEvent.withAction("loadList")

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

example/README.md

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:


dependencies:
  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';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
3
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
49
Learn more about scoring.

We analyzed this package on Jul 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

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' was not 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).

Dependencies

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.22.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test

Admin