knox 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 23
knox

knox pub style: pedantic license

An implementation of HydratedStorage using flutter_secure_storage, which interfaces with Keychain (iOS) and KeyStore (Android)

Usage #

final knox = await Knox.getInstance();

Example #

With HydratedBlocDelegate

BlocSupervisor.delegate = await KnoxDelegate.build();

Changelog #

1.0.0 #

  • Initial release

example/lib/main.dart

import 'package:bloc/bloc.dart';
import 'package:flutter/material.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:knox/knox.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  BlocSupervisor.delegate = await KnoxDelegate.build();

  runApp(Example());
}

/// Sample bloc with an [int] event and [int] state
class SampleBloc extends HydratedBloc<int, int> {
  @override
  int get initialState => super.initialState ?? 0;

  @override
  int fromJson(Map<String, dynamic> json) => json['state'];

  @override
  Stream<int> mapEventToState(int event) async* {
    yield event;
  }

  @override
  Map<String, dynamic> toJson(int state) => {'state': state};
}

/// Example counter app
class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      create: (context) => SampleBloc(),
      child: MaterialApp(
        home: BlocBuilder<SampleBloc, int>(
          builder: (context, state) {
            return Scaffold(
              body: Center(
                child: Text('$state'),
              ),
              floatingActionButton: FloatingActionButton(
                child: Icon(Icons.add),
                onPressed: () => BlocProvider.of<SampleBloc>(context).add(state + 1),
              ),
            );
          },
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  knox: ^1.0.0

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:knox/knox.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
32
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
23
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.13
  • Flutter: 1.17.5

Health issues and suggestions

Fix lib/src/knox.dart. (-68.36 points)

Analysis of lib/src/knox.dart failed with 4 errors:

line 27 col 54: Undefined class 'iOSOptions'.

line 35 col 67: Undefined class 'iOSOptions'.

line 44 col 67: Undefined class 'iOSOptions'.

line 56 col 39: Undefined class 'iOSOptions'.

Format lib/src/delegate.dart.

Run flutter format to format lib/src/delegate.dart.

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (hydrated_bloc).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
flutter_secure_storage ^3.3.1+1 3.3.3
hydrated_bloc ^3.0.0 3.1.0 5.0.3
Transitive dependencies
bloc 3.0.0 5.0.1
collection 1.14.12 1.14.13
file 5.2.1
intl 0.16.1
meta 1.1.8 1.2.1
path 1.7.0
path_provider 1.6.11
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
rxdart 0.23.1 0.24.1
sky_engine 0.0.99
synchronized 2.2.0+1
typed_data 1.1.6 1.2.0
vector_math 2.0.8
xdg_directories 0.1.0
Dev dependencies
flutter_test
pedantic ^1.8.0