redux_utils 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 38

Redux Utils #

Redux Utils helps to setup basic boiler plate to use redux.dart with flutter.

Note: Still experimenting. Suggestions and PR welcome.

Installing #

Specify the package in dev_dependencies like,

redux_utils: 0.0.3

Usage #

Note: Use this tool only with new flutter projects, it does not support existing projects. Please commit the initial project before using this tool.

  • First run flutter packages get after adding redux_utils to dev_dependencies
  • From root of the flutter project run flutter pub pub run redux_utils:main --setup
  • Then run flutter packages get
  • Next, run flutter pub pub run build_runner build

Redux setup is done, you can start using the package.

Packages Used #

dependencies:
    redux: '^3.0.0',
    redux_epics: '^0.10.0',
    flutter_redux: '^0.5.2',
    built_value: '^6.1.3',
    built_collection: '^4.0.0',
    shared_preferences: '0.4.2',
    rxdart: '^0.18.1',
    uri: '0.11.3+1',
    http: '^0.11.3+16',
    intl: '^0.15.7',

dev_dependencies:
    build_runner: '^1.0.0',
    built_value_generator: '^6.1.4',
    flutter_launcher_icons: '^0.6.1',

Folder Structure Used #

/actions
    - actions.dart
/api
    - api_client.dart
/data
    - app_repository.dart
    - preference_client.dart
/middleware
    - auth_middleware.dart
    - middleware.dart
/models
    - app_state.dart
    - models.dart
    - serializers.dart
/reducers
    - reducers.dart
/utils
    - assets.dart
    - icons.dart
    - utils.dart
/views
    /login
        - login_page.dart
    /home
        - home_page.dart
    - init_page.dart
- main.dart
- theme.dart

Author #

Hemanth Raj StackOverflow

1.0.0 #

  • Initial version, created by Stagehand

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:example/data/app_repository.dart';
import 'package:example/data/preference_client.dart';
import 'package:example/middleware/middleware.dart';
import 'package:example/models/models.dart';
import 'package:example/reducers/reducers.dart';
import 'package:example/theme.dart';
import 'package:example/views/init_page.dart';
import 'package:redux/redux.dart';
import 'package:shared_preferences/shared_preferences.dart';

Future<void> main() async {
  final SharedPreferences prefs = await SharedPreferences.getInstance();

  final AppRepository repository = AppRepository(
    preferencesClient: PreferencesClient(prefs: prefs),
  );

  runApp(
    Example(
      repository: repository,
    ),
  );
}

class Example extends StatefulWidget {
  final Store<AppState> store;

  Example({Key key, AppRepository repository})
      : store = Store<AppState>(
          reducer,
          middleware: middleware(repository),
          initialState: AppState.initState(),
        ),
        super(key: key);

  @override
  _ExampleState createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  Store<AppState> store;

  @override
  void initState() {
    super.initState();
    store = widget.store;
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return StoreProvider<AppState>(
      store: store,
      child: MaterialApp(
        navigatorKey: store.state.navigator,
        title: 'Example',
        theme: themeData,
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  redux_utils: ^0.0.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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_utils/redux_utils.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
91
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
52
Overall:
Weighted score of the above. [more]
38
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6

Health issues and suggestions

Document public APIs. (-1 points)

75 out of 75 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/parser/parser.dart. (-6.31 points)

Analysis of lib/parser/parser.dart reported 13 hints, including:

line 130 col 7: The member 'CodeExpression' can only be used within 'package:code_builder/src/specs/expression/code.dart' or a test.

line 136 col 24: The member 'CodeExpression' can only be used within 'package:code_builder/src/specs/expression/code.dart' or a test.

line 198 col 7: DO use curly braces for all flow control structures.

line 200 col 7: DO use curly braces for all flow control structures.

line 202 col 7: DO use curly braces for all flow control structures.

Fix lib/utils.dart. (-1.49 points)

Analysis of lib/utils.dart reported 3 hints:

line 15 col 7: DO use curly braces for all flow control structures.

line 17 col 7: DO use curly braces for all flow control structures.

line 21 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

Fix lib/dart_redux/main.dart. (-0.50 points)

Analysis of lib/dart_redux/main.dart reported 1 hint:

line 21 col 7: Use rethrow to rethrow a caught exception.

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 (built_value, recase).

Package is getting outdated. (-17.53 points)

The package was last published 61 weeks ago.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
args ^1.5.0 1.6.0
built_collection ^4.0.0 4.3.2
built_value ^6.1.3 6.8.2 7.0.9
code_builder ^3.1.3 3.2.0 3.2.1
dart_style ^1.1.3 1.3.3 1.3.4
path ^1.4.1 1.6.4
pubspec ^0.1.1 0.1.4
recase ^2.0.0+1 2.0.1 3.0.0
tuple ^1.0.2 1.0.3
Transitive dependencies
analyzer 0.38.5 0.39.6
analyzer_plugin 0.2.1
async 2.4.1
build 1.2.2
build_config 0.4.2
built_value_generator 6.8.2 7.0.9
charcode 1.1.3
checked_yaml 1.0.2
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
fixnum 0.10.11
front_end 0.1.27 0.1.29
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
json_annotation 3.0.1
kernel 0.3.27 0.3.29
logging 0.11.4
matcher 0.12.6
meta 1.1.8
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.9.3
pedantic 1.9.0
pub_semver 1.4.4
pubspec_parse 0.1.5
quiver 2.1.3
source_gen 0.9.4+6 0.9.5
source_span 1.7.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
uri 0.11.3+1
utf 0.9.0+5
watcher 0.9.7+14
yaml 2.2.0
Dev dependencies
test ^1.0.0