readAsString method

Future<String> readAsString()

Implementation

Future<String> readAsString() async {
  final db = await _openDb();
  final txn = db.transaction(_objectStoreName, idbModeReadOnly);
  final store = txn.objectStore(_objectStoreName);
  final object = await store.getObject(_filePath) as Map?;
  await txn.completed;
  if (object == null) {
    throw Exception('file not found: $_filePath');
  }
  return object['contents'] as String;
}