redux_prism 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

redux_prism #

Build Status Coverage Status pub package

Library used to easily access dispatched actions in a Redux Store. The library defines a pattern to catch new dispatched actions and listen to them in a reactive context. The StorePrism.middleware works like a proxy in the store middlewares and add every new action in the StorePrism.actions stream.

Usage #

import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';
import 'package:redux_prism/redux_prism.dart';

void main() => runApp(MessageApp());

class MessageApp extends StatelessWidget {
  Widget build(BuildContext context) =>
    StoreProvider<String>(
      store: Store<String>(
        (state, action) => state,
        middleware: [
          // register StorePrism "proxy" middleware
          StorePrism.middleware
        ],
      ),
      child: MaterialApp(
        title: 'Redux Prism',
        home: MessagePage()
      ),
    );
}

@immutable
class MessageAction {
  final String message;

  MessageAction({this.message});

  @override
  String toString() => 'MessageAction { message: $message }';
}

class MessagePage extends StatelessWidget {
  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();
  final TextEditingController _messageController = TextEditingController();

  MessagePage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) =>
    StorePrismListener(
      listen: (action) =>
        _scaffoldKey.currentState
          ..hideCurrentSnackBar()
          ..showSnackBar(SnackBar(content: Text(action.toString()))),
      child: Scaffold(
        key: _scaffoldKey,
        appBar: AppBar(title: Text('Redux Prism')),
        body: Column(
          children: <Widget>[
            TextField(
              controller: _messageController,
              decoration: InputDecoration(labelText: 'Message')
            ),
            StoreConnector<String, Function(String)>(
              converter: (Store<String> store) =>
                (message) => store.dispatch(MessageAction(message: message)),
              rebuildOnChange: false,
              builder: (_, dispatchMessageAction) =>
                OutlineButton(
                  onPressed: () => dispatchMessageAction(_messageController.text),
                  child: Text('SEND')
                )
            ),
          ],
        ),
      ),
    );
}

1.0.0 #

Added widget used to listen for dispatched actions in a cleanest way

  • Upgraded example app to use [StorePrismListener] and reduce boilerplate when listening actions in the view

0.1.2 #

Changing to Dart 2 stable version

  • Changing to stable sdk version
  • linking repository tag to every version in CHANGELOG.md

0.1.1 #

Dart 2 compatibility

  • Resolving sdk version

0.1.0 #

Initial version

  • Includes resource to extra power redux with ability to catch actions like a stream
  • Includes StorePrism class to access the actions stream and the injectable middleware responsible for catch and put new actions to the stream

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';
import 'package:redux_prism/redux_prism.dart';

void main() => runApp(MessageApp());

class MessageApp extends StatelessWidget {
  Widget build(BuildContext context) =>
    StoreProvider<String>(
      store: Store<String>(
        (state, action) => state,
        middleware: [
          // register StorePrism "proxy" middleware
          StorePrism.middleware
        ],
      ),
      child: MaterialApp(
        title: 'Redux Prism',
        home: MessagePage()
      ),
    );
}

@immutable
class MessageAction {
  final String message;

  MessageAction({this.message});

  @override
  String toString() => 'MessageAction { message: $message }';
}

class MessagePage extends StatelessWidget {
  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();
  final TextEditingController _messageController = TextEditingController();

  MessagePage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) =>
    StorePrismListener(
      listen: (action) =>
        _scaffoldKey.currentState
          ..hideCurrentSnackBar()
          ..showSnackBar(SnackBar(content: Text(action.toString()))),
      child: Scaffold(
        key: _scaffoldKey,
        appBar: AppBar(title: Text('Redux Prism')),
        body: Column(
          children: <Widget>[
            TextField(
              controller: _messageController,
              decoration: InputDecoration(labelText: 'Message')
            ),
            StoreConnector<String, Function(String)>(
              converter: (Store<String> store) =>
                (message) => store.dispatch(MessageAction(message: message)),
              rebuildOnChange: false,
              builder: (_, dispatchMessageAction) =>
                OutlineButton(
                  onPressed: () => dispatchMessageAction(_messageController.text),
                  child: Text('SEND')
                )
            ),
          ],
        ),
      ),
    );
}

Use this package as a library

1. Depend on it

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


dependencies:
  redux_prism: ^1.0.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:redux_prism/redux_prism.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
41
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [redux_prism] that is in a package requiring null.

Health suggestions

Format lib/redux_prism.dart.

Run flutter format to format lib/redux_prism.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
flutter_redux ^0.6.0 0.6.0
redux >=4.0.0 <5.0.0 4.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test