Search packages, repositories and app categories

Package detailsv0.1.0

broadcast_bloc

An extension to the bloc state management library which adds support for broadcasting state changes to stream channels.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
1.6K
Likes
26
Pub points
160

Install package

flutter pub add broadcast_bloc

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

BroadcastBloc is an extension of the Bloc library that enables broadcasting state changes to multiple stream channels, allowing efficient state distribution across different parts of an application. It enhances traditional Bloc functionality by supporting multiple listeners and broadcast streams, making it ideal for scenarios where several widgets or services need to react to the same state updates. Built on top of the well-established Bloc ecosystem, it maintains consistency with existing patterns while adding scalability. Designed for Flutter apps targeting Android, iOS, Web, macOS, Windows, and Linux.

Use cases

  • Real-time data synchronization
  • Multi-widget state sharing
  • Cross-module communication
  • Event-driven UI updates
  • Scalable state management in large apps

Key features

  • Broadcast stream support
  • Multiple listener capability
  • Seamless integration with Bloc
  • Efficient state propagation
  • Cross-platform compatibility

Suitable for

  • Large-scale Flutter applications
  • Apps requiring real-time updates
  • Developers using Bloc pattern
  • Teams needing shared state across modules
  • Complex UIs with synchronized components

Considerations

  • Higher memory usage due to broadcast streams
  • Potential for over-communication if not managed
  • Requires understanding of Streams and Bloc
  • Not suitable for simple one-off state changes
  • Needs careful handling of subscriptions to avoid leaks

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Broadcast Bloc

build coverage pub package style: bloc lint License: MIT

An extension to the bloc state management library which adds support for broadcasting state changes to stream channels.

Learn more at bloclibrary.dev!


Sponsors

Our top sponsors are shown below! [Become a Sponsor]


Quick Start 🚀

// Extend `BroadcastCubit` instead of `Cubit`.
// The package also exports:
// * `BroadcastBloc`
// * `BroadcastMixin`
class CounterCubit extends BroadcastCubit<int> {
  CounterCubit() : super(0);

  void increment() => emit(state + 1);
}

void main() {
  final controller = StreamController<String>(sync: true);
  final subscription = controller.stream.listen(print);
  final channel = StreamChannel(controller.stream, controller.sink);

  // Create an instance of the cubit.
  final cubit = CounterCubit()
    // Subscribe the channel.
    ..subscribe(channel)
    // Trigger a state change which will be broadcast to subscribed channels.
    ..increment()
    // Unsubscribe channel.
    ..unsubscribe(channel);

  subscription.cancel();
  cubit.close();
}

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package

No data available yet.