tbloc_dart 0.2.0

tBloC Dart #

Build Status

A dart library that helps you to implement the BLoC (Business Logic Component) pattern.

0.2.0 (2019-12-22)

Features #

  • First release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:tbloc_dart/core/base/base.dart';

import 'counter.bloc.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;
  final bloc = CounterBloc();

  MyHomePage({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: BlocProvider(
        bloc: bloc,
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  MaterialButton(
                    child: Text('INCREMENT'),
                    onPressed: () {
                      bloc.dispatchEvent(CounterBlocEvent.increment());
                    },
                  ),
                  MaterialButton(
                    child: Text('DECREMENT'),
                    onPressed: () {
                      bloc.dispatchEvent(CounterBlocEvent.decrement());
                    },
                  ),
                  MaterialButton(
                    child: Text('RESET'),
                    onPressed: () {
                      bloc.reset();
                    },
                  ),
                ],
              ),
              Text(
                'You have pushed the button this many times:',
              ),
              CounterWidget(),
            ],
          ),
        ),
      ),
    );
  }
}

class CounterWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final bloc = BlocProvider.of<CounterBloc>(context);

    return BlocBuilderWidget(
      bloc: bloc,
      builder: (context, CounterBlocState state) {
        return Text(
          '${state.counter}',
          style: Theme.of(context).textTheme.display1,
        );
      },
    );
  }
}

Use this package as a library

1. Depend on it

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


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

We analyzed this package on Feb 19, 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 issues and suggestions

Document public APIs. (-0.12 points)

64 out of 66 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

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 (subx).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
equatable ^1.0.1 1.1.0
flutter 0.0.0
meta ^1.1.8 1.1.8
rxdart ^0.23.1 0.23.1
subx ^0.4.0 0.4.0 0.5.0
Transitive dependencies
async 2.4.0
collection 1.14.11 1.14.12
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
pedantic 1.8.0+1
test ^1.9.4