toJson method
Implementation
Object? toJson(Object? Function(T? value) callback) {
if (_secondary == null) return callback(primary);
final entries = {
"primary": callback(primary),
"secondary": callback(_secondary),
}.entries.where((e) => e.value != null);
if (entries.isEmpty) return null;
return Map.fromEntries(entries);
}