adder static method

Adder adder({
  1. required CheckPoint parent,
  2. required dynamic onCancel(),
  3. required dynamic onDone(
    1. CheckPointDefect defect
    ),
  4. CheckPointDefect? currentDefect,
})

Implementation

static Adder adder({
  // required bool withoutdefect,
  required CheckPoint parent,
  required onCancel(),
  required onDone(CheckPointDefect defect),
  CheckPointDefect? currentDefect,
}) {
  var oufnessChooser = OufnessChooser(
    preSelected: currentDefect?.ereArt,
  );
  return Adder(
    'checkpointdefect',
    onSet: (json) {
      Map<String, dynamic> defect = json['checkpointdefect'];
      if (currentDefect != null) {
        defect = currentDefect.toJson()..addAll(defect);
      } else {
        debugPrint("set ${json['checkpointdefect'].toString()}");
        defect['PjNr'] = parent.pjNr;
        defect[CheckPointDefect.E1_key] = parent.category_index;
        defect[CheckPointDefect.E2_key] = parent.index;
        defect[CheckPointDefect.E3_key] = -1;
      }
      // if (withoutdefect) {
      //   defect[CheckPointDefect.kurzText_key] =
      //       parent.title + "  ohne Mangel";
      //   defect[CheckPointDefect.ereArt_key] = OufnessChooser.none;
      // } else {
      defect[CheckPointDefect.kurzText_key] =
              //parent.title +
              //"  " +
              ((defect[oufnessChooser.name].toString() ==
                      OufnessChooser.none.toString())
                  ? "ohne Mangel"
                  : ("Mangel " +
                      (CheckPointDefect.chipd(defect[oufnessChooser.name])
                              ?.label ??
                          ""))) //ahhh so thats why we learn functional programming
          // +
          // "Mangel "
          //  +
          // " #" +
          // json.hashCode.toRadixString(36)
          ;
      // }
      onDone(CheckPointDefect.fromJson(defect)!);
    },
    onCancel: onCancel,
    children: [
      oufnessChooser,
      //KurzTextCreator(), //creates the Mangel name //this way was utter BS i was kinda sleepy sorry lol
    ],
    textfieldList: [
      // InputData("KurzText", hint: "Name"), //removed according to #48

      InputData(CheckPointDefect.height_json_key,
          hint: S.current!.positionHeightHint,
          value: currentDefect?.height,
          verify: (val) => (val == null || val.length < 1)
              ? S.current!.heightNotOptional
              : null),
      InputData(
        CheckPointDefect.langText_key,
        hint: S.current!.langTextHint,
        value: currentDefect?.langText,
      ), //added according to #49
    ],
  );
}