flutter_built_redux 0.6.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 90

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

example/example.dart

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(
    reducerBuilder.build(),
    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;

  ConnectionExample(this.store);

  @override
  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;

  ConnectorExample(this.store);

  @override
  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> {
  CounterWidget();

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

  @override
  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();
  CounterActions._();

  ActionDispatcher<Null> get increment;
}

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

  int get count;
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_built_redux: ^0.6.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages 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';
  
Version Uploaded Documentation Archive
0.6.0 Aug 31, 2018 Go to the documentation of flutter_built_redux 0.6.0 Download flutter_built_redux 0.6.0 archive
0.5.0 Mar 2, 2018 Go to the documentation of flutter_built_redux 0.5.0 Download flutter_built_redux 0.5.0 archive
0.4.5 Feb 27, 2018 Go to the documentation of flutter_built_redux 0.4.5 Download flutter_built_redux 0.4.5 archive
0.4.4 Feb 26, 2018 Go to the documentation of flutter_built_redux 0.4.4 Download flutter_built_redux 0.4.4 archive
0.4.3 Feb 1, 2018 Go to the documentation of flutter_built_redux 0.4.3 Download flutter_built_redux 0.4.3 archive
0.4.2 Jan 19, 2018 Go to the documentation of flutter_built_redux 0.4.2 Download flutter_built_redux 0.4.2 archive
0.4.1 Jan 7, 2018 Go to the documentation of flutter_built_redux 0.4.1 Download flutter_built_redux 0.4.1 archive
0.4.0 Jan 7, 2018 Go to the documentation of flutter_built_redux 0.4.0 Download flutter_built_redux 0.4.0 archive
0.3.0 Oct 22, 2017 Go to the documentation of flutter_built_redux 0.3.0 Download flutter_built_redux 0.3.0 archive
0.2.0 Oct 13, 2017 Go to the documentation of flutter_built_redux 0.2.0 Download flutter_built_redux 0.2.0 archive

All 13 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
87
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
90
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance suggestions

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
built_redux >=6.1.1 <8.0.0 7.5.0
flutter 0.0.0
meta ^1.0.3 1.1.6
Transitive dependencies
analyzer 0.32.6 0.34.0
args 1.5.1
async 2.0.8
boolean_selector 1.0.4
build 0.12.8 1.0.1
built_collection 4.1.0
charcode 1.1.2
collection 1.14.11
convert 2.0.2
crypto 2.0.6
csslib 0.14.6
dart_style 1.1.3 1.2.1
fixnum 0.10.9
front_end 0.1.4+2 0.1.7
glob 1.1.7
html 0.13.3+3
http 0.12.0
http_multi_server 2.0.5
http_parser 3.1.3
io 0.3.3
js 0.6.1+1
json_rpc_2 2.0.9
kernel 0.3.4+2 0.3.7
logging 0.11.3+2
matcher 0.12.3+1 0.12.4
mime 0.9.6+2
multi_server_socket 1.0.2
node_preamble 1.4.4
package_config 1.0.5
package_resolver 1.0.6
path 1.6.2
plugin 0.2.0+3
pool 1.3.6
pub_semver 1.4.2
quiver 2.0.1
shelf 0.7.3+3
shelf_packages_handler 1.0.4
shelf_static 0.2.8
shelf_web_socket 0.2.2+4
sky_engine 0.0.99
source_gen 0.9.1+3
source_map_stack_trace 1.1.5
source_maps 0.10.8
source_span 1.4.1
stack_trace 1.9.3
stream_channel 1.6.8
string_scanner 1.0.4
term_glyph 1.0.1
test 1.5.1+1
test_api 0.2.1
test_core 0.2.0+1
typed_data 1.1.6
utf 0.9.0+5
vector_math 2.0.8
vm_service_client 0.2.6
watcher 0.9.7+10
web_socket_channel 1.0.9
yaml 2.1.15
Dev dependencies
build_runner >=0.6.0 <0.11.0
built_value >=5.0.0 <7.0.0 6.1.6
built_value_generator >=5.0.0 <7.0.0
flutter_test