loadFromSerializable method

void loadFromSerializable(
  1. List<Map<String, dynamic>> jsonRows
)

Implementation

void loadFromSerializable(List<Map<String, dynamic>> jsonRows) {
  if (!decoder.supportsJsonSerialization) {
    throw UnsupportedError(
      'Table "$tableName" decoder does not support JSON serialization. '
      'Implement toJson() and fromJson() in your RowDecoder.',
    );
  }
  _rowsByPrimaryKey.clear();
  _rows.clear();
  for (final json in jsonRows) {
    final row = decoder.fromJson(json);
    if (row == null) {
      SdkLogger.w('Failed to deserialize row in table "$tableName": $json');
      continue;
    }
    final primaryKey = decoder.getPrimaryKey(row);
    if (primaryKey != null) {
      _rowsByPrimaryKey[primaryKey] = row;
    } else {
      _rows.add(row);
    }
  }
  _refreshRowsNotifier();
  if (_rowNotifiers.isNotEmpty) {
    _notifyRowListeners(_rowNotifiers.keys.toList());
  }
}