Skip to main content

bloc

PackageKindProvides the roleNeedsChoose with
smf_blocinfrastructureState managementnothing-m bloc

bloc manages the state of screens with BLoC, through flutter_bloc 9.

What it adds to the app​

The module adds flutter_bloc: ^9.1.1 to the dependencies and nothing else, since BLoC needs neither a widget around the app nor start-up code.

Features with state​

A feature that keeps state supports BLoC through a variant keyed by the id of this module, bloc. The variant brings the Cubits or Blocs of the feature's screens and provides them where the screens need them. Usually the feature's composition file creates them, with the services they need. The variant depends on flutter_bloc with the constraint any, so the version comes from this module. See Write a feature module.

The built-in feature, home, has no state, so it works the same with bloc and without it.

Choosing it​

smf create asks which module manages the state of the app, and offers riverpod and None as well. To choose it without the question:

smf create my_app -m bloc

An app has at most one module that manages its state.