barbarian 0.2.26+3

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

Barbarian #

pub package

Barbarian is a fast and simple way to save data in NoSQL. It is a simple wrap of Shared preferences.

Initialize Barbarian #

await Barbarian.init();

Save #

Save any object, Map, List, HashMap etc. including all internal objects. Use your existing data classes as is.

Barbarian.write('string', 'cadena');
Barbarian.write('bool', true);
Barbarian.write('integer', 7);
Barbarian.write('double', 3.8);

Read #

Read data objects is as easy as

String str = Barbarian.read('string');
bool boole = Barbarian.read('bool');
int ibtg = Barbarian.read('integer');
double doub = Barbarian.read('double');

Delete #

Delete data for one key.

Barbarian.delete('string');

Remove all keys

Barbarian.destroy();

Get all keys #

Returns all keys for objects in the book.

List<String> allKeys = Barbarian.getAllKeys();

Complex data #

To save an object it is important that it has some form of serialization. Like this

class Item {
  int id;
  String name;
  List<String> locations;
  double price;
  int stock;
  bool active;

  Item(
      {this.id,
      this.name,
      this.locations,
      this.price,
      this.stock,
      this.active});

  Map<String, dynamic> toJson() => {
        'id': id,
        'name': name,
        'locations': locations,
        'price': price,
        'stock': stock,
        'active': active
      };

  Item.fromMap(Map<String, dynamic> map)
      : id = map['id'],
        name = map['name'],
        locations = List<String>.from(map['locations']),
        price = map['price'],
        stock = map['stock'],
        active = map['active'];

  @override
  String toString() => toJson().toString();
}

Save #

Barbarian.write('item', item);

Read #

Item oldItem = Barbarian.read('item', customDecode: (output) => Item.fromMap(output));

If you need more examples of complex data you can review the tests here.

[0.2.26] - 09/05/2019

  • Create first version of Barbarian

example/README.md

barbarian_example #

Simple example of how to use Barbarian

Use this package as a library

1. Depend on it

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


dependencies:
  barbarian: ^0.2.26+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:barbarian/barbarian.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
70
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

We analyzed this package on Dec 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.13.1+4

Health issues and suggestions

Document public APIs. (-1 points)

10 out of 10 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
shared_preferences ^0.5.2 0.5.5 0.5.6
synchronized ^2.1.0 2.1.1
Transitive dependencies
collection 1.14.11 1.14.12
flutter 0.0.0
meta 1.1.8
shared_preferences_macos 0.0.1
shared_preferences_platform_interface 1.0.1
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test