prefs_guard 0.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 75

Prefs Guard #

Prefs Guard is a data protection wrapper for local storage (Shared Prefs). supporting both IOS & Android.

- Notice :- Use Same GuardType through out the app to get the proper result.

Prefs guard supports three types of encryption formats #

GuardType.AES #

import 'package:prefs_guard/prefsguard.dart';

final prefs = PrefsGuard(GuardType.AES);

//Storing a value in local storage 
prefs.write(key: 'hello', value: 'flutter'); //encrypts using AES encryption.

//reading a value from local storage
final data= await prefs.read(key: 'hello');//decrypt using AES 

GuardType.Salsa20 #

import 'package:prefs_guard/prefsguard.dart';

final prefs = PrefsGuard(GuardType.Salsa20);

//Storing a value in local storage 
prefs.write(key: 'hello', value: 'flutter'); //encrypts using Salsa20 encryption.

//reading a value from local storage
final data= await prefs.read(key: 'hello');//decrypt using Salsa20 

GuardType.FerNet #

import 'package:prefs_guard/prefsguard.dart';

final prefs = PrefsGuard(GuardType.FerNet);

//Storing a value in local storage 
prefs.write(key: 'hello', value: 'flutter'); //encrypts using FerNet encryption.

//reading a value from local storage
final data= await prefs.read(key: 'hello');//decrypt using FerNet 

Clearing Prefs #

final prefs = PrefsGuard(GuardType.FerNet);
prefs.clearAll();

Contributing #

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update the tests as appropriate.

License #

MIT

[0.0.6] - Packages Updated #

[0.0.5] - Typo update. #

[0.0.4] - Null value bug fixed. #

[0.0.3] - Bug Fixes. #

[0.0.2] - Functionality for clearing local storage. #

[0.0.1] - Added Guard Types [AES,Salsa20,FerNet] #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:prefs_guard/prefsguard.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: PrefsGuardExample(),
    );
  }
}

class PrefsGuardExample extends StatefulWidget {
  @override
  _PrefsGuardExampleState createState() => _PrefsGuardExampleState();
}

class _PrefsGuardExampleState extends State<PrefsGuardExample> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
              child: Text('Wtite To Prefs'),
              onPressed: () => _writeToPrefs(GuardType.AES),
              color: Colors.blue,
            ),
            RaisedButton(
              child: Text('Read from prefs'),
              onPressed: () => _readFromPrefs(GuardType.AES),
              color: Colors.blue,
            )
          ],
        ),
      ),
    );
  }

  _writeToPrefs(GuardType type) async {
    switch (type) {
      case GuardType.AES:
        {
          final prefs = PrefsGuard(GuardType.AES);
          prefs.write(key: 'hello', value: 'flutter');
        }
        break;
      case GuardType.Salsa20:
        {
          final prefs = PrefsGuard(GuardType.Salsa20);
          prefs.write(key: 'hello', value: 'flutter');
        }
        break;
      case GuardType.FerNet:
        {
          final prefs = PrefsGuard(GuardType.FerNet);
          prefs.write(key: 'hello', value: 'flutter');
        }
        break;
    }
  }

  _readFromPrefs(GuardType type) async {
    switch (type) {
      case GuardType.AES:
        {
          final prefs = PrefsGuard(GuardType.AES);
          String value = await prefs.read(key: 'hello');
          print(value);
        }
        break;
      case GuardType.Salsa20:
        {
          final prefs = PrefsGuard(GuardType.Salsa20);
          String value = await prefs.read(key: 'hello');
          print(value);
        }
        break;
      case GuardType.FerNet:
        {
          final prefs = PrefsGuard(GuardType.FerNet);
          String value = await prefs.read(key: 'hello');
          print(value);
        }
        break;
    }
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  prefs_guard: ^0.0.6

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:prefs_guard/prefsguard.dart';
import 'package:prefs_guard/read.dart';
import 'package:prefs_guard/write.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
59
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
76
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

We analyzed this package on Jul 9, 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 does not support Flutter platform android

Because:

  • package:prefs_guard/prefsguard.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: linux

Package does not support Flutter platform ios

Because:

  • package:prefs_guard/prefsguard.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: linux

Package does not support Flutter platform macos

Because:

  • package:prefs_guard/prefsguard.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: linux

Package does not support Flutter platform web

Because:

  • package:prefs_guard/prefsguard.dart that imports:
  • package:shared_preferences/shared_preferences.dart that imports:
  • package:shared_preferences_linux/shared_preferences_linux.dart that declares support for platforms: linux

Package does not support Flutter platform windows

Because:

  • package:prefs_guard/prefsguard.dart that imports:
  • package:shared_preferences/shared_preferences.dart that declares support for platforms: android, ios, linux, macos, web

Package not compatible with SDK dart

Because:

  • prefs_guard that is a package requiring null.

Health suggestions

Format lib/write.dart.

Run flutter format to format lib/write.dart.

Maintenance suggestions

The package description is too short. (-14 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 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.1.0 <3.0.0
encrypt ^4.0.2 4.0.2
flutter 0.0.0
shared_preferences ^0.5.7+3 0.5.8
Transitive dependencies
args 1.6.0
asn1lib 0.6.5
charcode 1.1.3
clock 1.0.1
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
file 5.2.1
flutter_web_plugins 0.0.0
intl 0.16.1
meta 1.1.8 1.2.2
path 1.7.0
path_provider_linux 0.0.1+2
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
pointycastle 1.0.2
process 3.0.13
shared_preferences_linux 0.0.2+1
shared_preferences_macos 0.0.1+10
shared_preferences_platform_interface 1.0.4
shared_preferences_web 0.1.2+7
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0
Dev dependencies
flutter_test