flutter_cache 0.0.6 copy "flutter_cache: ^0.0.6" to clipboard
flutter_cache: ^0.0.6 copied to clipboard

outdated

A simple cache package for flutter. This package is a wrapper for shared preference and makes working with shared preference easier.

example/example.dart

import 'package:flutter_cache/flutter_cache.dart';

void main() async {

  // create new cache.
  Cache.remember('key', 'data'); 
  Cache.write('key', 'data'); 

  // add Cache lifetime on create
  Cache.remember('key', 'data', 120); 
  Cache.write('key', 'data', 120); 

  // load Cache by key
  Cache.load('key'); // This will load the cache data.

  // destroy single cache by key
  Cache.destroy('key');

  // destroy all cache
  Cache.clear();

  await Cache.remember('key', () {
    return 'test'; // or logic fetching data from api;
  });

  // or 

  await Cache.remember('key', () => 'test');

  Cache.remember('key', 'data', 120); // saved for 2 mins or 120 seconds
  Cache.write('key', 'data', 120);

  // multi depth map datatype.
  Cache.remember('key', { 
    'name' : 'Ashraf Kamarudin',
    'depth2' : {
      'name' : 'depth2',
      'depth3' : {
        'name': 'depth3'
      } 
    }
  });

  Cache.load('key'); // will return data in map datatype.
}
22
likes
0
pub points
84%
popularity

Publisher

unverified uploader

A simple cache package for flutter. This package is a wrapper for shared preference and makes working with shared preference easier.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on flutter_cache