getCachedData method

Future getCachedData(
  1. String path
)

returns data stored in the cache for the given key

Implementation

Future<dynamic> getCachedData(String path) async {
  Directory tempDir = await getTemporaryDirectory();
  try {
    // if(path.startsWith('/')) path = path.replaceFirst('/', '');
    path = path.split('/').last;
    if (kDebugMode) print('get cache.....$path.');
    bool isFound = await File('${tempDir.path}/$path.json').exists();
    if (kDebugMode) print('check temp finished $isFound');
    if (isFound) {
      String s = await File('${tempDir.path}/$path.json').readAsString();
      if (kDebugMode) print('cache.....$path.');
      return s;
    }
  } catch (e) {
    return null;
  }
}