store_builder 0.2.3

  • Installing
  • Versions
  • 41

store_builder #

Flux store and builder for Flutter.

Install #


Description #

store_builder provides Store, Value and StoreBuilder.

Store represents the state of the entire app. It can have multiple Values.

Value is a single value in the Store that identified by name.

StoreBuilder is a Widget that bind with a Value and rebuilt when the Value is updated.

Usage #

Add StoreProvider and Store to your app. It makes your widgets allows to access the Store.

void main() => runApp(MaterialApp(
      title: 'Your app',
      home: StoreProvider(
        store: Store(),
        child: MyHomePage(),

Use StoreBuilder<V> to build widgets with a value. It is bind to individual values in the Store by name.

child: StoreBuilder<int>(
  name: "counter",
  builder: (BuildContext context, Value<int> value) {
    if (value.error != null) {
        return ErrorWidget(value.error);
    } else if (value.value == null) {
        return LoadingWidget();
    return YourWidget(value.value);

You can gets a Value from Store by Store#value method, and gets the value by Value#value property.

// gets a Value.
final Value<int> value = store.value<int>("counter");

// Value has value and error.
final int counter = value.value ?? 0;
// final Object error = value.error;

// Update the value.
value.value = counter + 1;

When a Value is updates by Value#value and Value#error, all StoreBuilders associated with that name are rebuilt.

For separation of responsibility, we recommend that you implement store operations independently as Actions.

class Names {
  static const String counter = 'counter';

class Values {
  static Value<int> counter(Store store)
      => store.value<int>(Names.counter);

class IncrementCounterAction implements Action {
  Future<void> run(Store store) async {
    final Value<int> value = Values.counter(store);
    final int counter = value.value ?? 0;
    value.value = counter + 1;

And widgets calls the action.

class YourWidget extends StatelessWidget {
  void incrementCounter() {

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  store_builder: ^0.2.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:store_builder/store_builder.dart';
Version Uploaded Documentation Archive
0.2.3 Mar 13, 2019 Go to the documentation of store_builder 0.2.3 Download store_builder 0.2.3 archive
0.2.1 Mar 12, 2019 Go to the documentation of store_builder 0.2.1 Download store_builder 0.2.1 archive
0.2.0 Mar 12, 2019 Go to the documentation of store_builder 0.2.0 Download store_builder 0.2.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jun 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Provide a file named (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Support latest dependencies. (-5 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and store_builder.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8