toJson method
Serialises to a JSON-compatible map. Omits null / empty fields.
Implementation
Map<String, dynamic> toJson() => {
if (userId != null) 'userId': userId,
if (currentRoute != null) 'currentRoute': currentRoute,
if (extra.isNotEmpty) 'extra': extra,
};