getById method

Future<T?> getById(
  1. int id
)

Get By Id in Box<T>

Implementation

Future<T?> getById(int id) async {
  final res = await _indexedDB.db.getById(id);
  if (res == null) return null;
  if (res.type != RecordType.json) return null;
  final raf = await _indexedDB.dbFile.open();
  final data = await (res as JsonRecord).getJsonData(raf);
  await raf.close();
  if (data == null) return null;
  return _adapter.fromMap(_adapter.decodeData(data));
}