toJson property

Map<String, dynamic> Function(T data)? toJson
final

Function to serialize data into a Map<String, dynamic> (for persistence).

Despite the Json naming, this returns a plain Dart map — not a JSON-encoded string. This means Drift/SQLite toMap() methods work as-is, with no intermediate JSON encoding step:

toJson: (user) => user.toMap(), // Drift’s native toMap works directly

Implementation

final Map<String, dynamic> Function(T data)? toJson;