local_cache_sync 1.0.0 copy "local_cache_sync: ^1.0.0" to clipboard
local_cache_sync: ^1.0.0 copied to clipboard

outdated

Cache json map to local file with Dart:io. Read cahce with sync api.

local_cache_sync #

A new Flutter package project.

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Usage #

Set Cache Path.

getTemporaryDirectory().then((uri) {
      LocalCacheSync.instance.setCachePath(uri.path);
});

Create class load from loader.


class Device {
  final String uuid;
  final String name;
  final int type;

  Device({
    this.uuid,
    this.name,
    this.type,
  });

  Device.formJson(Map<String, dynamic> map)
      : this(
          uuid: map['uuid'],
          name: map['name'],
          type: map['type'],
        );

  static LocalCacheLoader get _loader => LocalCacheLoader('device');

  static List<Device> all() {
    return _loader.all
        .map<Device>(
          (cache) => Device(
            uuid: cache.id,
            name: cache.value['name'],
            type: cache.value['type'],
          ),
        )
        .toList();
  }

  LocalCacheObject save() {
    return Device._loader.saveById(uuid, jsonMap);
  }

  Map<String, dynamic> get jsonMap => {
        'uuid': uuid,
        'name': name,
        'type': type,
      };
}
7
likes
0
pub points
77%
popularity

Publisher

unverified uploader

Cache json map to local file with Dart:io. Read cahce with sync api.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on local_cache_sync