toSerializable method
Implementation
List<Map<String, dynamic>> toSerializable({
List<Map<String, dynamic>> excludeRows = const [],
Set<String> excludeRequestIds = const {},
}) {
if (!decoder.supportsJsonSerialization) {
throw UnsupportedError(
'Table "$tableName" decoder does not support JSON serialization. '
'Implement toJson() and fromJson() in your RowDecoder.',
);
}
final Iterable<Map<String, dynamic>> all;
if (hasPrimaryKey) {
all = _rowsByPrimaryKey.values.map((row) => decoder.toJson(row)!);
} else {
all = _rows
.where(
(e) =>
e.requestId == null || !excludeRequestIds.contains(e.requestId),
)
.map((e) => decoder.toJson(e.row)!);
}
if (excludeRows.isEmpty) return all.toList();
final remaining = List<Map<String, dynamic>>.of(excludeRows);
final out = <Map<String, dynamic>>[];
for (final row in all) {
final matchIndex = remaining.indexWhere((e) => _jsonEquals(e, row));
if (matchIndex >= 0) {
remaining.removeAt(matchIndex);
} else {
out.add(row);
}
}
return out;
}