OptionConstraint constructor

OptionConstraint({
  1. required ConstraintType type,
  2. Object? min,
  3. Object? max,
  4. Object? quant,
  5. Object? list,
})

Implementation

OptionConstraint({
  required ConstraintType type,
  Object? min,
  Object? max,
  Object? quant,
  Object? list,
}) : _wrapped = $js.OptionConstraint(
        type: type.toJS,
        min: switch (min) {
          int() => min.jsify()!,
          double() => min.jsify()!,
          null => null,
          _ => throw UnsupportedError(
              'Received type: ${min.runtimeType}. Supported types are: int, double')
        },
        max: switch (max) {
          int() => max.jsify()!,
          double() => max.jsify()!,
          null => null,
          _ => throw UnsupportedError(
              'Received type: ${max.runtimeType}. Supported types are: int, double')
        },
        quant: switch (quant) {
          int() => quant.jsify()!,
          double() => quant.jsify()!,
          null => null,
          _ => throw UnsupportedError(
              'Received type: ${quant.runtimeType}. Supported types are: int, double')
        },
        list: switch (list) {
          List<double>() => list.toJSArray((e) => e),
          List<int>() => list.toJSArray((e) => e),
          List() => list.toJSArrayString(),
          null => null,
          _ => throw UnsupportedError(
              'Received type: ${list.runtimeType}. Supported types are: List<double>, List<int>, List<String>')
        },
      );