init static method

Future<void> init(
  1. NativeConfigRequest configModel
)

Implementation

static Future<void> init(NativeConfigRequest configModel) async {
  if (configModel.token != null && configModel.token!.isNotEmpty) {
    key = configModel.token!;
  }
  var listDetectorType = <DetectionType>[];

  if (configModel.isEnableSmile ?? true) {
    listDetectorType.add(DetectionType.SMILE);
  }
  if (configModel.isEnableLookStraight ?? true) {
    listDetectorType.add(DetectionType.LOOK_STRAIGHT);
  }
  if (configModel.isEnableLookRight ?? true) {
    listDetectorType.add(DetectionType.LOOK_RIGHT);
  }
  if (configModel.isEnableLookLeft ?? true) {
    listDetectorType.add(DetectionType.LOOK_LEFT);
  }
  if (configModel.isEnableEyesBlink ?? true) {
    listDetectorType.add(DetectionType.EYES_BLINK);
  }
  if (configModel.bg != null) {
    AppTheme.primaryColor = HexColor(configModel.bg!);
    AppTheme.onBackground = HexColor(configModel.color!);
  }
  config = SkdConfig(
    color: configModel.color == null
        ? AppTheme.primaryColor
        : HexColor(configModel.color!),
    bg: configModel.color == null
        ? AppTheme.primaryColor
        : HexColor(configModel.color!),
    isHistoy: configModel.isHistory ?? true,
    isSignature: configModel.isSignature ?? true,
    isShowInfo: configModel.isShowInfo ?? true,
    readOnlyInfo: configModel.readOnlyInfo ?? false,
    readOnlyId: configModel.readOnlyId ?? true,
    isSaveCapture: configModel.isSaveCapture ?? false,
    isAutoMatching: configModel.isAutoMatching ?? true,
    faceConfig: FaceConfig(
      listDetectorType: listDetectorType,
      doingStep: configModel.takeDoingStep ?? listDetectorType.length,
      detectionLastStep: DetectionLastStep.TAKE_PORTRAITS,
      detectionDisplay: configModel.isRandomDetect ?? true
          ? DetectionDisplay.RANDOM
          : DetectionDisplay.DEFAULT,
    ),
  );
  preferences = await SharedPreferences.getInstance();
  FileUtils.init();
}