A collections of packages providing additional functionality for working with bloc

Overview

Bloc Extensions

License: MIT GitHub Workflow Status melos style: very good analysis


A collections of packages providing additional functionality for working with bloc.

Index

Packages

Package Version
action_bloc pub
action_bloc_test pub
flutter_action_bloc pub
flutter_action_bloc_hooks pub
flutter_bloc_hooks pub

Bloc Hooks

Bloc hooks provide an easy way to use blocs from HookWidgets and other hooks without needing to access the current BuildContext or unnecessary deep nesting using BlocBuilders and BlocListeners.

Example

class CounterText extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final counter = useBlocState<CounterCubit, int>();

    return Text('$counter');
  }
}

Action Blocs

ActionBlocs are bloc with an additional stream for actions (side effects). When using sealed classes (for example with freezed) as state side effects cannot easily be modeled inside the state. Examples for such side effects include showing error messages or navigating to another screen.

Example

class CounterCubit extends ActionCubit<int, String> {
  CounterCubit() : super(0);

  void increment() {
    emit(state + 1);

    if (state % 15 == 0) {
      emitAction('FizzBuzz');
    } else if (state % 5 == 0) {
      emitAction('Buzz');
    } else if (state % 3 == 0) {
      emitAction('Fizz');
    }
  }
}

class CounterText extends HookWidget {
  const CounterText({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final counter = useBlocState<CounterCubit, int>();

    useBlocActionListener<CounterCubit, String>((context, action) {
      final snackBar = SnackBar(
        content: Text(action),
      );

      ScaffoldMessenger.of(context).showSnackBar(snackBar);
    });

    return Text('$counter');
  }
}

Contributing

This repository uses melos for managing all packages. To get started first install melos and then run its bootstrap command.

dart pub global activate melos

melos bootstrap 

More information about melos can be found on https://melos.invertase.dev. All available scripts can be seen in melos.yaml.

You might also like...

Notes-bloc-flutter - Proyecto para administrar tareas implementando patrón bloc

notes_bloc A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Jan 9, 2022

Flutter bloc cubit test knowdge - Flutter bloc cubit test knowdge

Flutter Bloc Simple Api This project is using weather api for featch data and di

Jan 3, 2022

Flutter bloc infinite list - A sample application to learn flutter bloc the correct way

flutter_bloc_infinite_list A sample application to learn flutter bloc the correc

Aug 22, 2022

Flutter bloc example - An app for State management using BLoC pattern in Flutter

Flutter bloc example - An app for State management using BLoC pattern in Flutter

Flutter BLoC My first app for State management using BLoC pattern in Flutter Col

Jun 16, 2022

An example of "reactive/streaming repository" as a solution for BLoC to BLoC communication

An example of

Reactive Repositories An example of listening to a Stream from repository layer (instead of explicitly using get/fetch) as a solution for BLoC to BLoC

Jan 3, 2023

CoVAC is an all-in-one Covid info toolkit app, providing users the facility to check for available slots along with receiving the latest updates related to the pandemic and the virus.

CoVAC is an all-in-one Covid info toolkit app, providing users the facility to check for available slots along with receiving the latest updates related to the pandemic and the virus.

CoVAC - Covid 19 Vaccine Availability Checker Introduction 📌 CoVAC is an android application developed to provide users the facility to check the ava

Dec 29, 2021

A Flutter plugin providing signature pad for drawing smooth signatures.

A Flutter plugin providing signature pad for drawing smooth signatures.

A Flutter plugin providing Signature Pad for drawing smooth signatures. Library is written in pure Dart/Flutter environment to provide support for all

Dec 21, 2022

Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map.

Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map.

Custom Radio Group List Flutter package to create list of radio button, by providing a list of objects it can be a String list or list of Map. Feature

Nov 30, 2021

Created application for team to help each other with providing food they want

Created application for team to help each other with providing food they want

Food wishes app When you login or create your account, you can write what do you wish right now as a separate card, using "Edit" button. If you no lon

Nov 29, 2021
Owner
Aljoscha Grebe
Aljoscha Grebe
A port of kotlin-stdlib for Dart/Flutter including immutable collections (KtList, KtMap, KtSet) and other packages

kt.dart This project is a port of Kotlin's Kotlin Standard library for Dart/Flutter projects. It's a useful addition to dart:core and includes collect

Pascal Welsch 460 Jan 9, 2023
⚒️ A monorepo containing a collection of packages that provide useful functionality for building CLI applications in Dart.

⚒️ Dart CLI Utilities A monorepo containing a collection of packages that provide useful functionality for building CLI applications in Dart. Document

Invertase 14 Oct 17, 2022
soTired is an application for cognitive fatigue assessment. It includes a stand-alone Android app for fatigue detection and an additional part for data management and further analysis.

Motivation soTired is an application for cognitive fatigue assessment. It includes a stand-alone Android app for fatigue detection and an additional p

Team Ulster 2.0 5 Oct 22, 2021
Additional alignments to help make your layouts more readable (TopLeft, TopRight, etc)

extra alignments Why should Center get all the love? This package adds additional alignments to help make your layouts more readable. The full set inc

gskinner team 13 Jan 6, 2023
Petrus Nguyễn Thái Học 193 Dec 29, 2022
Functional extensions to Dart collections.

collection_ext A set of extension methods for Dart collections, designed for the purpose of making it easier to write concise, functional-programming-

Yingxin Wu 7 Nov 21, 2022
Immutable Dart collections via the builder pattern.

Built Collections for Dart Introduction Built Collections are immutable collections using the builder pattern. Each of the core SDK collections is spl

Google 250 Dec 20, 2022
🌈 Repository for a compass project, basically an App for displaying bank transfers, with API requests, Flag persistence, Infinite Scroll, Error Handling, Unit Tests, Extract Sharing working with SOLID, BLoC and Designer Patterns.

?? Green Bank Aplicação desenvolvida em Flutter com intuito de trabalhar conexão com API, Gerenciamento de estado usando BLoC, Refatoração, Arquitetur

André Guerra Santos 28 Oct 7, 2022
An extension to the bloc state management library which automatically persists and restores bloc states.

⚠️ Attention: This repository has been moved to https://github.com/felangel/bloc and is now read-only! An extension to the bloc state management libra

Felix Angelov 189 Nov 17, 2022