toGraph method

Map<String, Object?> toGraph(
  1. T row
)

Normalize a transport row into canonical graph fields.

Override this at adapters whose model does not expose toJson. Keeping this conversion on the transport boundary prevents providers/widgets from owning transport-specific normalization logic.

Implementation

Map<String, Object?> toGraph(T row) {
  if (row is Map<String, Object?>) return Map.unmodifiable(row);
  try {
    // Dynamic access is intentionally isolated at this adapter boundary.
    // ignore: avoid_dynamic_calls
    final encoded = (row as dynamic).toJson() as Map<String, dynamic>;
    return Map.unmodifiable(encoded.cast<String, Object?>());
  } on Object catch (error) {
    throw TerminalError(
      'EntityTransport $runtimeType cannot normalize ${row.runtimeType}: '
      '$error',
    );
  }
}