toMap method

Map<String, dynamic> toMap()

toMap returns the event as a map.

Implementation

Map<String, dynamic> toMap() {
  Map<String, dynamic> ret = {
    "type": type.toString().split(".").last,
    "waitDuration": waitDuration?.inMilliseconds,
    "time": time.millisecondsSinceEpoch,
    "widgetName": widgetName,
  };
  switch (type) {
    case FlutsterTestEventType.key:
      ret["logicalKey.keyId"] = keyEvent?.logicalKey.keyId;
      ret["physicalKey.usbHidUsage"] = keyEvent?.physicalKey.usbHidUsage;
      ret["keyEvent.duration"] = keyEvent?.timeStamp.inMilliseconds;
      ret["typedText"] = ifJsonAble(typedText) ?? "";
      ret["keyEventDown"] = keyEventDown;
      ret["character"] = ifJsonAble(keyEvent?.character) ?? "";
      ret["logicalKey.keyLabel"] = keyEventKeyLabel;
      break;
    case FlutsterTestEventType.tap:
      ret["tapStart.dx"] = tapStart?.dx;
      ret["tapStart.dy"] = tapStart?.dy;
      ret["tapDuration"] = tapDuration?.inMilliseconds;
      ret["tapStop.dx"] = tapStop?.dx;
      ret["tapStop.dy"] = tapStop?.dy;
      break;
    case FlutsterTestEventType.screenShot:
      ret["screenShot"] = screenShotBytes == null ? null : screenShotToB64();
      ret["screenShotComparisonFunctionName"] =
          screenShotComparisonFunctionName ??
              defaultScreenshotComparisonFunctionName;
      ret["screenShotAcceptancePctThreshold"] =
          screenShotAcceptancePctThreshold;
      ret["pixelMatchingTolerance"] = pixelMatchingTolerance;
      ret["IMEDBlurRatio"] = iMEDBlurRatio;
      ret["IMEDSigma"] = iMEDSigma;
      if (screenShotMatchResult != null) {
        ret["screenShotMatchResult"] = screenShotMatchResult;
      }
      break;
    default:
      assert(false, "Unknown FlutsterTestEventType in toMap");
      break;
  }
  return (ret);
}