fromJson static method

Customization fromJson(
  1. dynamic jsonObject
)

Allows you to deserialize object.

Implementation

static Customization fromJson(jsonObject) {
  var result = Customization();
  result.testSetters = {};

  result.theme = CustomizationTheme.getByValue(jsonObject["theme"]);

  result.showStatusMessages = jsonObject["showStatusMessages"];
  result.showResultStatusMessages = jsonObject["showResultStatusMessages"];
  result.showHelpAnimation = jsonObject["showHelpAnimation"];
  result.showNextPageAnimation = jsonObject["showNextPageAnimation"];
  result.showBackgroundMask = jsonObject["showBackgroundMask"];

  result.cameraFrameBorderWidth = jsonObject["cameraFrameBorderWidth"];
  result.cameraFrameLineLength = jsonObject["cameraFrameLineLength"];
  result.cameraFrameShapeType = FrameShapeType.getByValue(jsonObject["cameraFrameShapeType"]);
  result.cameraFrameOffsetWidth = jsonObject["cameraFrameOffsetWidth"];

  result.status = jsonObject["status"];
  result.resultStatus = jsonObject["resultStatus"];
  result.multipageButtonText = jsonObject["multipageButtonText"];

  result.cameraFrameDefaultColor = _intToColor(jsonObject["cameraFrameDefaultColor"]);
  result.cameraFrameActiveColor = _intToColor(jsonObject["cameraFrameActiveColor"]);
  result.statusTextColor = _intToColor(jsonObject["statusTextColor"]);
  result.resultStatusTextColor = _intToColor(jsonObject["resultStatusTextColor"]);
  result.resultStatusBackgroundColor = _intToColor(jsonObject["resultStatusBackgroundColor"]);
  result.multipageButtonBackgroundColor = _intToColor(jsonObject["multipageButtonBackgroundColor"]);
  result.tintColor = _intToColor(jsonObject["tintColor"]);
  result.activityIndicatorColor = _intToColor(jsonObject["activityIndicatorColor"]);
  result.statusBackgroundColor = _intToColor(jsonObject["statusBackgroundColor"]);
  result.cameraPreviewBackgroundColor = _intToColor(jsonObject["cameraPreviewBackgroundColor"]);
  result.backgroundMaskColor = _intToColor(jsonObject["backgroundMaskColor"]);
  result.multipageButtonTextColor = _intToColor(jsonObject["multipageButtonTextColor"]);

  result.statusPositionMultiplier = _toDouble(jsonObject["statusPositionMultiplier"]);
  result.resultStatusPositionMultiplier = _toDouble(jsonObject["resultStatusPositionMultiplier"]);
  result.toolbarSize = _toDouble(jsonObject["toolbarSize"]);
  result.backgroundMaskAlpha = _toDouble(jsonObject["backgroundMaskAlpha"]);
  result.customStatusPositionMultiplier = _toDouble(jsonObject["customStatusPositionMultiplier"]);
  result.cameraFrameVerticalPositionMultiplier = _toDouble(jsonObject["cameraFrameVerticalPositionMultiplier"]);
  result.cameraFrameLandscapeAspectRatio = _toDouble(jsonObject["cameraFrameLandscapeAspectRatio"]);
  result.cameraFrameCornerRadius = _toDouble(jsonObject["cameraFrameCornerRadius"]);
  result.cameraFramePortraitAspectRatio = _toDouble(jsonObject["cameraFramePortraitAspectRatio"]);
  result.livenessAnimationPositionMultiplier = _toDouble(jsonObject["livenessAnimationPositionMultiplier"]);
  result.nextPageAnimationStartDelay = _toDouble(jsonObject["nextPageAnimationStartDelay"]);
  result.nextPageAnimationEndDelay = _toDouble(jsonObject["nextPageAnimationEndDelay"]);
  result.activityIndicatorPortraitPositionMultiplier =
      _toDouble(jsonObject["activityIndicatorPortraitPositionMultiplier"]);
  result.activityIndicatorLandscapePositionMultiplier =
      _toDouble(jsonObject["activityIndicatorLandscapePositionMultiplier"]);
  result.cameraPreviewVerticalPositionMultiplier = _toDouble(jsonObject["cameraPreviewVerticalPositionMultiplier"]);
  result.multipageButtonPositionMultiplier = _toDouble(jsonObject["multipageButtonPositionMultiplier"]);

  result.multipageAnimationFrontImage = _dataFromBase64(jsonObject["multipageAnimationFrontImage"]);
  result.multipageAnimationBackImage = _dataFromBase64(jsonObject["multipageAnimationBackImage"]);
  result.borderBackgroundImage = _dataFromBase64(jsonObject["borderBackgroundImage"]);
  result.helpAnimationImage = _dataFromBase64(jsonObject["helpAnimationImage"]);
  result.closeButtonImage = _dataFromBase64(jsonObject["closeButtonImage"]);
  result.captureButtonImage = _dataFromBase64(jsonObject["captureButtonImage"]);
  result.cameraSwitchButtonImage = _dataFromBase64(jsonObject["cameraSwitchButtonImage"]);
  result.torchButtonOnImage = _dataFromBase64(jsonObject["torchButtonOnImage"]);
  result.torchButtonOffImage = _dataFromBase64(jsonObject["torchButtonOffImage"]);
  result.changeFrameButtonExpandImage = _dataFromBase64(jsonObject["changeFrameButtonExpandImage"]);
  result.changeFrameButtonCollapseImage = _dataFromBase64(jsonObject["changeFrameButtonCollapseImage"]);
  result.livenessAnimationImage = _dataFromBase64(jsonObject["livenessAnimationImage"]);
  result.multipageButtonImage = _dataFromBase64(jsonObject["multipageButtonImage"]);

  result.customLabelStatus = jsonObject["customLabelStatus"];
  result.cameraFrameLineCap = Cap.getByValue(jsonObject["cameraFrameLineCap"]);
  result.uiCustomizationLayer = jsonObject["uiCustomizationLayer"];
  result.statusTextFont = Font.fromJson(jsonObject["statusTextFont"]);
  result.resultStatusTextFont = Font.fromJson(jsonObject["resultStatusTextFont"]);
  result.multipageButtonTextFont = Font.fromJson(jsonObject["multipageButtonTextFont"]);

  result.helpAnimationImageTransformsIOS = ViewContentMode.getByValue(jsonObject["helpAnimationImageContentMode"]);
  result.multipageAnimationFrontImageTransformsIOS =
      ViewContentMode.getByValue(jsonObject["multipageAnimationFrontImageContentMode"]);
  result.multipageAnimationBackImageTransformsIOS =
      ViewContentMode.getByValue(jsonObject["multipageAnimationBackImageContentMode"]);
  result.livenessAnimationImageTransformsIOS =
      ViewContentMode.getByValue(jsonObject["livenessAnimationImageContentMode"]);
  result.borderBackgroundImageTransformsIOS =
      ViewContentMode.getByValue(jsonObject["borderBackgroundImageContentMode"]);

  if (jsonObject["helpAnimationImageMatrix"] != null) {
    List<double> array = [];
    for (var value in jsonObject["helpAnimationImageMatrix"]) {
      array.add(value.toDouble());
    }
    result.helpAnimationImageTransformsAndroid = array;
  } else {
    result.helpAnimationImageTransformsAndroid = null;
  }
  if (jsonObject["multipageAnimationFrontImageMatrix"] != null) {
    List<double> array = [];
    for (var value in jsonObject["multipageAnimationFrontImageMatrix"]) {
      array.add(value.toDouble());
    }
    result.multipageAnimationFrontImageTransformsAndroid = array;
  } else {
    result.multipageAnimationFrontImageTransformsAndroid = null;
  }
  if (jsonObject["multipageAnimationBackImageMatrix"] != null) {
    List<double> array = [];
    for (var value in jsonObject["multipageAnimationBackImageMatrix"]) {
      array.add(value.toDouble());
    }
    result.multipageAnimationBackImageTransformsAndroid = array;
  } else {
    result.multipageAnimationBackImageTransformsAndroid = null;
  }
  if (jsonObject["livenessAnimationImageMatrix"] != null) {
    List<double> array = [];
    for (var value in jsonObject["livenessAnimationImageMatrix"]) {
      array.add(value.toDouble());
    }
    result.livenessAnimationImageTransformsAndroid = array;
  } else {
    result.livenessAnimationImageTransformsAndroid = null;
  }
  if (jsonObject["borderBackgroundImageMatrix"] != null) {
    List<double> array = [];
    for (var value in jsonObject["borderBackgroundImageMatrix"]) {
      array.add(value.toDouble());
    }
    result.borderBackgroundImageTransformsAndroid = array;
  } else {
    result.borderBackgroundImageTransformsAndroid = null;
  }

  result.colors = CustomizationColors.fromJson(jsonObject["colors"]);
  result.fonts = CustomizationFonts.fromJson(jsonObject["fonts"]);
  result.images = CustomizationImages.fromJson(jsonObject["images"]);
  result.timings = CustomizationTimings.fromJson(jsonObject["timings"]);
  result.contentModes = CustomizationContentModes.fromJson(jsonObject["contentModes"]);
  result.matrices = CustomizationMatrices.fromJson(jsonObject["matrices"]);

  return result;
}