flutter_built_redux 0.6.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 73

Pub codecov.io

flutter_built_redux #

built_redux bindings for Flutter.

By creating a Widget that extends StoreConnector you get automatic subscribing to your redux store, and you component will only call setState when the store triggers and the values you take from the store in connect change!

Examples #

counter example

todo_mvc, written by Brian Egan

Why you may need flutter_built_redux #

For the same reason you would want to use redux with react.

from the flutter tutorial:

In Flutter, change notifications flow “up” the widget hierarchy by way of callbacks, while current state flows “down” to the stateless widgets that do presentation.

Following this pattern requires you to send any state or state mutator callbacks that are common between your widgets down from some common ancestor.

With larger applications this is very tedious, leads to large widget constructors, and this pattern causes flutter to rerun the build function on all widgets between the ancestor that contains the state and the widget that actually cares about it. It also means your business logic and network requests live in your widget declarations.

built_redux gives you a predicable state container that can live outside your widgets and perform logic in action middleware.

flutter_built_redux lets a widget to subscribe to the pieces of the redux state tree that it cares about. It also lets lets widgets dispatch actions to mutate the redux state tree. This means widgets can access and mutate application state without the state and state mutator callbacks being passed down from its ancestors!

0.6.0 #

  • Migrate to Dart 2
  • Bump dependencies to more recent versions

0.5.0 #

  • Breaking changes:
    • Renamed the typdef WidgetBuilder to StoreConnectionBuilder to avoid possible namespacing issues.

0.4.5 #

  • create explicit typedefs for funcs passed to StoreConnection, as the new Function syntax messes up the analyzer

0.4.4 #

  • add StoreConnection, which is an implementation of store connector that takes a connect & builder function as parameters.
  • add example file.

0.4.3 #

  • Move built_value dependency to dev_dependencies and bump to ^5.0.0

0.4.2 #

  • Use assert for type assertions rather than thowing exceptions

0.4.1 #

  • Add changelog

0.4.0 #

  • Breaking changes:

    • Remove state builder generic from StoreConnector

    • Made StoreConnectorState private

  • Perform check on storeSub in didChangeDependencies to return early if a subscription to the store has already been created.

  • Raise exceptions if the store found by inheritFromWidgetOfExactType has different generics than the StoreConnector

  • Add unit tests


library example;

import 'package:built_redux/built_redux.dart';
import 'package:flutter_built_redux/flutter_built_redux.dart';
import 'package:flutter/material.dart' hide Builder;
import 'package:built_value/built_value.dart';

part 'example.g.dart';

void main() {
  // create the store
  final store = new Store(
    new Counter(),
    new CounterActions(),

  runApp(new ConnectionExample(store));
  // or comment the line above and uncomment the line below
  // runApp(new ConnectorExample(store));

/// an example using `StoreConnection`
class ConnectionExample extends StatelessWidget {
  final Store<Counter, CounterBuilder, CounterActions> store;


  Widget build(BuildContext context) => new MaterialApp(
        title: 'flutter_built_redux_test',
        home: new ReduxProvider(
          store: store,
          child: new StoreConnection<Counter, CounterActions, int>(
            connect: (state) => state.count,
            builder: (BuildContext context, int count, CounterActions actions) {
              return new Scaffold(
                body: new Row(
                  children: <Widget>[
                    new RaisedButton(
                      onPressed: actions.increment,
                      child: new Text('Increment'),
                    new Text('Count: $count'),

/// an example using a widget that implements `StoreConnector`
class ConnectorExample extends StatelessWidget {
  final Store<Counter, CounterBuilder, CounterActions> store;


  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'flutter_built_redux_test',
      home: new ReduxProvider(
        store: store,
        child: new CounterWidget(),

/// [CounterWidget] impelments [StoreConnector] manually
class CounterWidget extends StoreConnector<Counter, CounterActions, int> {

  int connect(Counter state) => state.count;

  Widget build(BuildContext context, int count, CounterActions actions) =>
      new Scaffold(
        body: new Row(
          children: <Widget>[
            new RaisedButton(
              onPressed: actions.increment,
              child: new Text('Increment'),
            new Text('Count: $count'),

// Built redux counter state, actions, and reducer

ReducerBuilder<Counter, CounterBuilder> reducerBuilder =
    new ReducerBuilder<Counter, CounterBuilder>()
      ..add(CounterActionsNames.increment, (s, a, b) => b.count++);

abstract class CounterActions extends ReduxActions {
  factory CounterActions() => new _$CounterActions();

  ActionDispatcher<Null> get increment;

abstract class Counter implements Built<Counter, CounterBuilder> {
  factory Counter() => new _$Counter._(count: 0);

  int get count;

Use this package as a library

1. Depend on it

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

  flutter_built_redux: ^0.6.0

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:flutter_built_redux/flutter_built_redux.dart';
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 May 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health suggestions

Fix lib/flutter_built_redux.dart. (-0.50 points)

Analysis of lib/flutter_built_redux.dart reported 1 hint:

line 95 col 17: 'inheritFromWidgetOfExactType' is deprecated and shouldn't be used. Use dependOnInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Maintenance suggestions

Package is getting outdated. (-73.70 points)

The package was last published 90 weeks ago.

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.

Update README.md. (-2 points)

1 image link is insecure (e.g. http://codecov.io/github/davidmarne/flutter_built_redux/coverage.svg?branch=master), use https URLs instead.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
built_redux >=6.1.1 <8.0.0 7.5.11
flutter 0.0.0
meta ^1.0.3 1.1.8
Transitive dependencies
_fe_analyzer_shared 3.0.0
analyzer 0.39.8
args 1.6.0
async 2.4.1
boolean_selector 2.0.0
build 1.3.0
built_collection 4.3.2
charcode 1.1.3
collection 1.14.12
convert 2.1.1
coverage 0.13.9
crypto 2.1.5
csslib 0.16.1
dart_style 1.3.6
fixnum 0.10.11
glob 1.2.0
html 0.14.0+3
http 0.12.1
http_multi_server 2.2.0
http_parser 3.1.4
io 0.3.4
js 0.6.1+1
logging 0.11.4
matcher 0.12.6
mime 0.9.6+3
multi_server_socket 1.0.2
node_interop 1.1.1
node_io 1.1.1
node_preamble 1.4.9
package_config 1.9.3
path 1.7.0
pedantic 1.9.0
pool 1.4.0
pub_semver 1.4.4
quiver 2.1.3
shelf 0.7.5
shelf_packages_handler 2.0.0
shelf_static 0.2.8
shelf_web_socket 0.2.3
sky_engine 0.0.99
source_gen 0.9.5
source_map_stack_trace 2.0.0
source_maps 0.10.9
source_span 1.7.0
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
test 1.14.5
test_api 0.2.16
test_core 0.3.5
typed_data 1.1.6
vector_math 2.0.8
vm_service 4.0.4
watcher 0.9.7+15
web_socket_channel 1.1.0
webkit_inspection_protocol 0.7.3
yaml 2.2.1
Dev dependencies
build_runner >=0.6.0 <0.11.0
built_value >=5.0.0 <7.0.0 7.1.0
built_value_generator >=5.0.0 <7.0.0