flock 0.6.0

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 51

flock #

Build Status

Coordinate Flutter widgets' states with event sourcing.

Inspired by Redux.

Design #

Usage #

import 'package:flock/flock.dart';

// Events
class E {}

class Minus extends E {
  Minus(this.value);

  final String value;
}

class Add extends E {
  Add(this.v);

  final int v;
}

// Store
final store = createStore<E>();

// In you widget:
class BW extends StatelessWidget {
  int sum(int prev, List<E> events) {
    var result = prev ?? 0;
    for (var event in events) {
      if (event is Add)
        result += event.v;
      else if (event is Minus)
        result -= int.tryParse(event.value) ?? 0;
    }
    return result;
  }

  @override
  Widget build(BuildContext context) {
    return StoreBuilder( 
      build: (BuildContext context, int p) => Text(
            '$p',
            textDirection: TextDirection.ltr,
          ),
      store: store, // use store from wherever you like
      projector: sum
    );
  }
}


Limits #

This is still an early WIP. The future plan includes:

  • better Flutter integration
  • serialization & time travel support

License #

MIT

[0.0.1] - 2019/1/8

  • Initial release.

[0.0.2] - 2019/1/8

  • Update readme.

[0.0.3] - 2019/1/8

  • Add basic documents to public interface.

[0.0.4] - 2019/1/9

  • Add Store#get as a shorthand of Store#projectWith

[0.0.5] - 2019/1/9

  • Rename EventStore to Store

[0.0.6] - 2019/1/9

  • Hide Store#replaceEvents from user

[0.0.7] - 2019/1/9

  • Add basic Flutter integration.

[0.0.8] - 2019/1/10

  • Update interface to match Redux better.
  • Add ShakeBack enhancer.
  • Add StoreBuilder interface.

[0.0.9]

  • Rename build in StoreBuilder's params to builder
  • Eliminate rebuilds caused by StoreBuilder

[0.0.10]

  • Add description
  • Rename ShakeBack API

[0.0.11]

  • Add example
  • Update description

[0.0.12]

  • Rename StoreWidget interface
  • Remove Projectable from signature of Projector
  • Remove EventStack, using chronological List instead

[0.1.0]

  • Separate Reducer and Initializer
  • Rename InnerStore to StoreForEnhancer
  • Expose more methods in StoreForEnhancer

[0.1.1]

  • Remove withShakeBack
  • Fix StackOverflow when get Store#cursor
  • Remove unnecessary dependencies.

[0.3.0]

  • Update interface
  • Add UseCase

[0.3.2]

  • Add ObservableStateLifecycle integration

[0.4.0]

  • Update observeStore interface

[0.4.1]

  • Use active_observers

[0.5.0]

  • Update file structure.

[0.6.0]

  • Update observeStore

Use this package as a library

1. Depend on it

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


dependencies:
  flock: ^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:flock/flock.dart';
  
Version Uploaded Documentation Archive
0.6.0 Mar 17, 2019 Go to the documentation of flock 0.6.0 Download flock 0.6.0 archive
0.5.0 Mar 8, 2019 Go to the documentation of flock 0.5.0 Download flock 0.5.0 archive
0.4.1 Mar 7, 2019 Go to the documentation of flock 0.4.1 Download flock 0.4.1 archive
0.4.0 Mar 7, 2019 Go to the documentation of flock 0.4.0 Download flock 0.4.0 archive
0.3.2 Mar 7, 2019 Go to the documentation of flock 0.3.2 Download flock 0.3.2 archive
0.3.1 Mar 5, 2019 Go to the documentation of flock 0.3.1 Download flock 0.3.1 archive
0.3.0 Mar 5, 2019 Go to the documentation of flock 0.3.0 Download flock 0.3.0 archive
0.1.1 Jan 15, 2019 Go to the documentation of flock 0.1.1 Download flock 0.1.1 archive
0.0.12 Jan 11, 2019 Go to the documentation of flock 0.0.12 Download flock 0.0.12 archive
0.0.11 Jan 10, 2019 Go to the documentation of flock 0.0.11 Download flock 0.0.11 archive

All 20 versions...

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

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

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Fix lib/integration/observe_store.dart. (-43.75 points)

Analysis of lib/integration/observe_store.dart failed with 2 errors:

line 7 col 3: Undefined class 'ObserveState'.

line 7 col 32: The function 'observeState' isn't defined.

Fix lib/integration/store_builder.dart. (-0.50 points)

Analysis of lib/integration/store_builder.dart reported 1 hint:

line 10 col 25: Use ; instead of {} for empty constructor bodies.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

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

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
active_observers ^0.4.0 0.4.1 0.6.1
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
Dev dependencies
flutter_test
matcher ^0.12.3