toJson method

Map<String, Object?> toJson()

Implementation

Map<String, Object?> toJson() => {
  'index': index,
  'position': position,
  if (parent != null) 'parent': parent,
  if (branch != null) 'branch': branch,
  if (name != null) 'name': name,
  'auto': auto,
  if (tags.isNotEmpty) 'tags': tags,
  // Omitted for a screen, so the overwhelmingly common step's record stays
  // the size it has always been — and so a reader written before there was
  // anything but screens reads one correctly by ignoring the key.
  if (kind != ScenarioStepKind.screen) 'kind': kind.name,
  if (ms != null) 'ms': ms,
  if (image != null) 'image': image,
  if (format != null) 'format': format,
  if (width != null) 'width': width,
  if (height != null) 'height': height,
  if (tree != null) 'tree': tree,
  if (file != null) 'file': file,
  if (mimeType != null) 'mimeType': mimeType,
  if (bytes != null) 'bytes': bytes,
  if (notification case var notification?)
    'notification': {
      'body': notification.body,
      if (notification.title != null) 'title': notification.title,
      if (notification.appName != null) 'appName': notification.appName,
    },
  if (keys != null) 'keys': keys,
  if (semantics != null) 'semantics': semantics,
  'texts': texts,
  if (address.isNotEmpty) 'address': address,
  if (statusBrightness != null) 'statusBrightness': statusBrightness,
  if (navBrightness != null) 'navBrightness': navBrightness,
  if (verb != null) 'verb': verb,
  if (target != null) 'target': target,
  if (aim != null) 'aim': aim!.toJson(),
  if (events != null) 'events': events,
  if (eventCount != null) 'eventCount': eventCount,
  if (eventChannels != null) 'eventChannels': eventChannels,
  if (eventTitles != null) 'eventTitles': eventTitles,
  if (eventsDropped != null) 'eventsDropped': eventsDropped,
  if (frames != null) 'frames': frames,
  if (frameCount != null) 'frameCount': frameCount,
  if (frameWidth != null) 'frameWidth': frameWidth,
  if (frameHeight != null) 'frameHeight': frameHeight,
  if (frameIntervalMs != null) 'frameIntervalMs': frameIntervalMs,
  if (framesDropped != null) 'framesDropped': framesDropped,
  // All omitted in the healthy case, so a normal step's record stays the
  // size it was. Each writes its field rather than a literal so the shape
  // extractor carries the field's doc into `docs/capabilities.md`.
  if (!settled) 'settled': settled,
  if (!waited) 'waited': waited,
  if (!landed) 'landed': landed,
  if (guessed != null) 'guessed': guessed,
  if (stillTicking.isNotEmpty) 'stillTicking': stillTicking,
  if (digest != null) 'digest': digest,
  if (strayFrames > 0) 'strayFrames': strayFrames,
  if (keyboard != null) 'keyboard': keyboard,
  if (unchanged) 'unchanged': unchanged,
  if (failure != null) 'failure': failure,
};