bloc_stream 4.3.1

Dart native js
Flutter Android iOS web

A simple package that helps you to implement the BLoC pattern in your applications.

A simple package that helps you to implement the BLoC pattern in your applications.

The BlocStream class is just a Stream<State> with a couple extra methods added to reduce boilerplate. You can subclass it and add your own methods to implement your business logic.

A BlocStream is also a sink of actions. By calling add with an action function (BlocStreamAction<YourState>), the bloc will then call that action and merge the resulting Stream<State> into the output stream.

Here is an example BLoC that provides a list of events:

import 'package:bloc_stream/bloc_stream.dart';
import 'package:equatable/equatable.dart';
import 'package:example/event_repository.dart';

// Actions
class EventsActions {
  static final BlocStreamAction<List<Event>, EventsBloc> fetch =
    (value, bloc, controller) => bloc
      .repository
      .list()
      .then(controller.add);
}

// Bloc
class EventsBloc extends BlocStream<List<Event>> {
  EventBloc(this.repository) : super(null);
  final EventRepository repository;
}

Usage with Flutter #

See flutter_bloc_stream.

You can also use this package in combination with Provider and StreamBuilder.

You could also use a StreamProvider from the Provider package.

2
likes
110
pub points
47%
popularity

A simple package that helps you to implement the BLoC pattern in your applications.

Repository (GitLab)
View/report issues

Documentation

API reference

Uploader

tim@fostle.com

License

MIT (LICENSE)

Dependencies

meta, rxdart

More

Packages that depend on bloc_stream