toJson method

Map<String, dynamic> toJson()

Produces a Map that can be serialized to JSON.

Implementation

Map<String, dynamic> toJson() {
  final geoJson = geo?.toJson();
  return {
    ...?unknown,
    if (id != null) 'id': id,
    if (username != null) 'username': username,
    if (email != null) 'email': email,
    if (ipAddress != null) 'ip_address': ipAddress,
    // ignore: deprecated_member_use_from_same_package
    if (segment != null) 'segment': segment,
    if (data?.isNotEmpty ?? false) 'data': data,
    // ignore: deprecated_member_use_from_same_package
    if (extras?.isNotEmpty ?? false) 'extras': extras,
    if (name != null) 'name': name,
    if (geoJson != null && geoJson.isNotEmpty) 'geo': geoJson,
  };
}