getListByParentId method

Future<List<T>> getListByParentId(
  1. int parentId
)

Get List By Parent Id in Box<T>

Implementation

Future<List<T>> getListByParentId(int parentId) async {
  List<T> results = [];
  for (var record in _indexedDB.allActiveRecordList) {
    if (record.type != RecordType.json) continue;
    final jsonRec = (record as JsonRecord);
    if (jsonRec.parentId == parentId) {
      // read json data
      final raf = await _indexedDB.dbFile.open();
      final data = await jsonRec.getJsonData(raf);
      await raf.close();
      if (data == null) continue;
      final value = _adapter.fromMap(_adapter.decodeData(data));
      results.add(value);
    }
  }
  return results;
}