explaingit

felangel/bloc

12,451DartAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

Bloc is a state management library for Flutter and AngularDart apps that separates business logic from the UI using a predictable event-in, state-out pattern, making apps easier to test and debug.

Mindmap

mindmap
  root((repo))
    What it does
      State management
      Event to state flow
      Business logic separation
    Packages
      bloc core
      flutter_bloc widgets
      hydrated_bloc
      replay_bloc
      bloc_test
      bloc_concurrency
    Tech Stack
      Dart
      Flutter
      AngularDart
    License
      MIT open source
    Audience
      Flutter developers
      Mobile developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Manage login state in a Flutter app so the UI automatically updates when a user logs in or out.

USE CASE 2

Build an infinite-scrolling list in Flutter where more items load automatically as the user scrolls.

USE CASE 3

Add undo and redo support to any part of a Flutter app using the replay_bloc package.

USE CASE 4

Write automated tests for app business logic without needing a running UI or device.

Tech stack

DartFlutterAngularDart

Getting it running

Difficulty · moderate Time to first run · 30min

Requires an existing Flutter project, recommended in the official Flutter documentation.

MIT license, use freely in personal or commercial projects without restriction.

In plain English

This repository is a state management library for apps built with Flutter (Google's mobile and web toolkit) or AngularDart. State management is the problem of tracking what an app is doing at any given moment: whether a user is logged in, what items are in a cart, what data has loaded from a server. Without a clear structure for this, the logic can become tangled and difficult to test. The library is built around the BLoC pattern, which stands for Business Logic Component. The core idea is to draw a clean line between what the user sees and the rules that govern how the app behaves. Events come in from the UI, a bloc processes them according to defined rules, and emits new states that the UI then reflects. This predictable one-way flow makes it easier to trace bugs, write automated tests, and reuse logic across different parts of an app. The repository ships as a family of separate packages rather than one large bundle. The core bloc package contains the fundamental logic. flutter_bloc provides widgets that connect a Flutter UI to a bloc. hydrated_bloc adds persistence so that state survives an app restart. replay_bloc adds undo and redo support. bloc_test provides utilities for writing automated tests against blocs. bloc_concurrency handles situations where multiple events arrive at once and you need to decide whether to queue them, run them in parallel, or drop duplicates. bloc_lint adds linting rules to catch common mistakes before code ships. Official documentation, tutorials, and migration guides live at bloclibrary.dev. The README links to worked examples covering a counter, an infinite scrolling list, a login screen, a GitHub search feature, and a weather app. These serve as starting points for new projects or as references for common patterns. The library is MIT-licensed and free to use in personal and commercial projects. It is listed as a recommended option in the official Flutter documentation and has an active Discord community.

Copy-paste prompts

Prompt 1
Using the Flutter Bloc library, set up a login screen where the UI shows a spinner while logging in, an error message on failure, and navigates home on success.
Prompt 2
Help me build an infinite scrolling list in Flutter using flutter_bloc that fetches more items from an API as the user reaches the bottom.
Prompt 3
Using hydrated_bloc in my Flutter app, save the current cart state so it is still there when the user closes and reopens the app.
Prompt 4
Show me how to write a bloc_test unit test for a Flutter Bloc that handles adding items to a shopping cart.
Prompt 5
I need to handle rapid button taps in my Flutter app without processing duplicate events. Show me how to use bloc_concurrency to drop duplicates.
Open on GitHub → Explain another repo

← felangel on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.