ScannerOption constructor

ScannerOption({
  1. required String name,
  2. required String title,
  3. required String description,
  4. required OptionType type,
  5. required OptionUnit unit,
  6. Object? value,
  7. OptionConstraint? constraint,
  8. required bool isDetectable,
  9. required Configurability configurability,
  10. required bool isAutoSettable,
  11. required bool isEmulated,
  12. required bool isActive,
  13. required bool isAdvanced,
  14. required bool isInternal,
})

Implementation

ScannerOption({
  /// Option name using lowercase a-z, numbers, and dashes.
  required String name,

  /// Printable one-line title.
  required String title,

  /// Longer description of the option.
  required String description,

  /// The type that `value` will contain and that is needed for
  /// setting this option.
  required OptionType type,

  /// Unit of measurement for this option.
  required OptionUnit unit,

  /// Current value of the option if relevant. Note the type passed here must
  /// match the type specified in `type`.
  Object? value,

  /// Constraint on possible values.
  OptionConstraint? constraint,

  /// Can be detected from software.
  required bool isDetectable,

  /// Whether/how the option can be changed.
  required Configurability configurability,

  /// Can be automatically set by the backend.
  required bool isAutoSettable,

  /// Emulated by the backend if true.
  required bool isEmulated,

  /// Option is active and can be set/retrieved.  If false, the
  /// `value` field will not be set.
  required bool isActive,

  /// UI should not display this option by default.
  required bool isAdvanced,

  /// Option is used for internal configuration and should never be displayed
  /// in the UI.
  required bool isInternal,
}) : _wrapped = $js.ScannerOption(
        name: name,
        title: title,
        description: description,
        type: type.toJS,
        unit: unit.toJS,
        value: switch (value) {
          bool() => value.jsify()!,
          double() => value.jsify()!,
          List<double>() => value.toJSArray((e) => e),
          int() => value.jsify()!,
          List<int>() => value.toJSArray((e) => e),
          String() => value.jsify()!,
          null => null,
          _ => throw UnsupportedError(
              'Received type: ${value.runtimeType}. Supported types are: bool, double, List<double>, int, List<int>, String')
        },
        constraint: constraint?.toJS,
        isDetectable: isDetectable,
        configurability: configurability.toJS,
        isAutoSettable: isAutoSettable,
        isEmulated: isEmulated,
        isActive: isActive,
        isAdvanced: isAdvanced,
        isInternal: isInternal,
      );