flutter_memory_cache 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 52

Language: English | 中文简体

flutter_memory_cache #

flutter memory cache in Map with ttl support.

Notice #

  • It's not for the logical cache because eviction will automatically remove cache.
  • It use TTL(Time To Live) to make sure data can be refresh.
  • This lib have NOT been fully tested yet, Please do NOT use it in production.

Getting Started #

Add dependency

   flutter_memory_cache: #latest version


 MemoryCache memoryCache = MemoryCache();
 dynamic cache1 = {'name': 'obj1'};
 var cache2 = {'name': 'obj2'};
 memoryCache.put('obj1', cache1); //default ttl 60 seconds
     'cache2', cache2, 5); //cache2 will be invalidate in 5 seconds
 var ret = memoryCache.get('cache2');//ret is null
 print('ret is $ret');
 ret = memoryCache.get('cache1');
 print('cache1 is $ret'); // cache1 is {name: obj1}

version #

0.0.2 #

  • add evict check when cache been changed.
  • add example
  • document is ready

0.0.1 #

  • core function available


import 'dart:io';

import 'package:flutter_memory_cache/flutter_memory_cache.dart';

main() {
  // default config
  MemoryCache memoryCache = MemoryCache();
  dynamic cache1 = {'name': 'obj1'};
  var cache2 = {'name': 'obj2'};
  memoryCache.put('cache1', cache1); //default ttl 60 seconds
      'cache2', cache2, 5); //cache2 will be invalidate in 30 seconds
  sleep(Duration(seconds: 6));
  var ret = memoryCache.get('cache2'); //
  print('cache2 is $ret');
  assert(ret == null);
  ret = memoryCache.get('cache1');
  print('cache1 is $ret');
  assert(ret['name'] == "obj1");

Use this package as a library

1. Depend on it

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

  flutter_memory_cache: ^0.0.2

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:flutter_memory_cache/flutter_memory_cache.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 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 not compatible with SDK dart


  • flutter_memory_cache that is a package requiring null.

Maintenance suggestions

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


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
system_info ^0.1.2 0.1.3
Transitive dependencies
collection 1.14.12 1.14.13
file_utils 0.1.4
globbing 0.3.1
meta 1.1.8 1.2.1
path 1.7.0
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies