crypted_preferences 0.0.2

crypted_preferences #

Flutter preferences management with crypto capabilities

For now preferences are not crypted, I'm waiting for FFI to land :)

But you can still use this package to have multiple preferences files in Desktop, mobile and web.

Usage #

final preferences = await Preferences.preferences({path: 'pathToPrefs'});

await preferences.setBool('boolKey', false);


Get and set preference: #

Getter have an optional param defaultValue if the preference if not set.

dynamic get(key) bool getBool(key) Future

Custom object save as preferences #

You can use save custom object using the mixin WithPreferencesSerializable on your class, it will serialize your object into a map to save it.

Retrieve an object from a preference key: WithPreferencesSerializable getPreferencesSerializable(String key, WithPreferencesSerializable Function(Map<String, Object>))

Retrieve an object from a preference file WithPreferencesSerializable getPreferences(String key, WithPreferencesSerializable Function(Map<String, Object>))

Remove preference: #


Clear all preference: #



import 'package:crypted_preferences/crypted_preferences.dart';

main() async {
  final prefs = await Preferences.preferences(path: './example/prefs');

  print(prefs.getPreferencesSerializable('complex', (data) => _Complex.fromMap(data)));

  await prefs.setString('test', 'ok');
  await prefs.setPreferencesSerializable('complex', _Complex('works', 5));

class _Complex with WithPreferencesSerializable {
  final String test;
  final int testInt;

  _Complex(this.test, this.testInt);

  static _Complex fromMap(Map<String, Object> data) {
    return _Complex(data['test'], data['testInt']);

  Map<String, Object> toMap() {
    return {
      'test': test,
      'testInt': testInt,

  String toString() {
    return '_Complex{test: $test, testInt: $testInt}';

Use this package as a library

1. Depend on it

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

  crypted_preferences: ^0.0.2

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

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

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/src/preferences_base.dart. (-7.71 points)

Analysis of lib/src/preferences_base.dart reported 16 hints, including:

line 51 col 25: Don't explicitly initialize variables to null.

line 51 col 39: Use = to separate a named parameter from its default value.

line 55 col 29: Don't explicitly initialize variables to null.

line 55 col 46: Use = to separate a named parameter from its default value.

line 60 col 12: Don't explicitly initialize variables to null.

Format lib/src/preferences.dart.

Run dartfmt to format lib/src/preferences.dart.

Format lib/src/preferences_io.dart.

Run dartfmt to format lib/src/preferences_io.dart.

Format lib/src/preferences_web.dart.

Run dartfmt to format lib/src/preferences_web.dart.

Maintenance issues and suggestions

Provide a file named (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

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.

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


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
meta ^1.1.7 1.1.8
Dev dependencies
pedantic ^1.8.0+1
test ^1.6.8