fromJson static method

DVTouch? fromJson(
  1. Object? json
)

Implementation

static DVTouch? fromJson(Object? json) {
  if (json is! Map) return null;
  final DateTime? at = DateTime.tryParse('${json['at']}');
  if (at == null) return null;
  String? text(String key) {
    final Object? value = json[key];
    return value is String && value.isNotEmpty ? value : null;
  }

  return DVTouch(
    at: at,
    source: text('utm_source'),
    medium: text('utm_medium'),
    campaign: text('utm_campaign'),
    content: text('utm_content'),
    term: text('utm_term'),
    id: text('utm_id'),
    fbclid: text('fbclid'),
    gclid: text('gclid'),
    fbc: text('fbc'),
    referrer: text('referrer'),
    landingPath: text('landing_path'),
  );
}