flutter_built_redux_hooks 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 42

Build Status

Usage #

ReduxProvider usage:

runApp(ReduxProvider(
	store: new Store(
      createReducer(),
      State(),
      StateActions(),
    ),
	child: child,
));

useReduxActions usage:

HookBuilder(
  builder: (context) {
    MyActions actions = useReduxActions<MyActions>();

    return RaisedButton(
        onPressed: () => actions.someAction(),
        child: new Text('dispatch action'),
    ),
  },
)

useReduxActions usage:

HookBuilder(
  builder: (context) {
    SubState sub = useReduxState<State, SubState>((s) => s.sub);
    return Text(sub.textProp);
  },
)

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:built_collection/built_collection.dart';
import 'package:built_redux/built_redux.dart';
import 'package:example/redux/app_actions.dart';
import 'package:example/redux/app_state.dart';
import 'package:flutter/material.dart';
import 'package:example/redux/app_reducer.dart';
import 'package:flutter_built_redux_hooks/flutter_built_redux_hooks.dart';
import 'package:flutter_hooks/flutter_hooks.dart' hide Store;

final store = Store<AppState, AppStateBuilder, AppActions>(
    appReducer, AppState(), AppActions());

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

class TodoApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ReduxProvider(
      store: store,
      child: MaterialApp(
        home: TodoScreen(),
      ),
    );
  }
}

class TodoScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('example'),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            AddTodo(),
            TodosList(),
          ],
        ),
      ),
    );
  }
}

class AddTodo extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final actions = useReduxActions<AppActions>();
    final todos = useReduxState<AppState, BuiltList<Todo>>((s) => s.todos);
    return Column(
      children: <Widget>[
//        TextFormField(),
        RaisedButton(
          child: Text('Add Todo'),
          onPressed: () {
            final todo = Todo((b) => b.title = 'New Todo ${todos.length}');
            actions.addTodo(todo);
          },
        ),
      ],
    );
  }
}

class TodosList extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final todos = useReduxState<AppState, BuiltList<Todo>>((s) => s.todos);
    useReduxStateOnInitialBuildEffect<AppState, BuiltList<Todo>>((s) => s.todos,
        (s) {
      Scaffold.of(context)
        ..removeCurrentSnackBar()
        ..showSnackBar(SnackBar(content: Text('Initial Snackbar')));
    });
    useReduxStateOnDidChangeEffect<AppState, BuiltList<Todo>>((s) => s.todos,
        (s) {
      Scaffold.of(context)
        ..removeCurrentSnackBar()
        ..showSnackBar(SnackBar(content: Text(s.last.title)));
    });

    return ListView.builder(
        primary: false,
        shrinkWrap: true,
        itemCount: todos.length,
        itemBuilder: (context, index) {
          final todo = todos.elementAt(index);
          return ListTile(
            title: Text(todo.title),
            onTap: () {
              Navigator.of(context).push(MaterialPageRoute(
                builder: (context) => Scaffold(
                      appBar: AppBar(
                        title: Text('Second page'),
                      ),
                    ),
              ));
            },
          );
        });
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_built_redux_hooks: ^0.1.2

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

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • flutter_built_redux_hooks that is a package requiring null.

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (flutter_hooks, provider).

Package is getting outdated. (-43.84 points)

The package was last published 75 weeks ago.

The package description is too short. (-4 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
built_redux ^7.5.2 7.5.11
flutter 0.0.0
flutter_hooks ^0.2.1 0.2.1 0.11.0
provider ^1.3.0 1.6.1 4.2.0
Transitive dependencies
_fe_analyzer_shared 5.0.0
analyzer 0.39.12
args 1.6.0
async 2.4.2
boolean_selector 2.0.0
build 1.3.0
built_collection 4.3.2
built_value 7.1.0
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
coverage 0.14.0
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.2
logging 0.11.4
matcher 0.12.8
meta 1.1.8 1.2.1
mime 0.9.6+3
node_interop 1.1.1
node_io 1.1.1
node_preamble 1.4.12
package_config 1.9.3
path 1.7.0
pool 1.4.0
pub_semver 1.4.4
quiver 2.1.3
shelf 0.7.7
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.5
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
test 1.15.2
test_api 0.2.17
test_core 0.3.10
typed_data 1.1.6 1.2.0
vector_math 2.0.8
vm_service 4.1.0
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 ^1.0.0
built_value_generator ^6.0.0
built_value_test ^6.3.0
flutter_test
pedantic ^1.4.0 1.9.0 1.9.1