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({
  /// The option name using lowercase ASCII letters, numbers, and dashes.
  /// Diacritics are not allowed.
  required String name,

  /// A printable one-line title.
  required String title,

  /// A longer description of the option.
  required String description,

  /// The data type contained in the `value` property, which
  /// is needed for setting this option.
  required OptionType type,

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

  /// The current value of the option, if relevant. Note that the data
  /// type of this property must match the data type specified in
  /// `type`.
  Object? value,

  /// Defines [OptionConstraint] on the current scanner option.
  OptionConstraint? constraint,

  /// Indicates that this option can be detected from software.
  required bool isDetectable,

  /// Indicates whether and how the option can be changed.
  required Configurability configurability,

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

  /// Emulated by the scanner driver if true.
  required bool isEmulated,

  /// Indicates the option is active and can be set or retrieved. If false,
  /// the `value` property will not be set.
  required bool isActive,

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

  /// Indicates that the 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.toJS,
          double() => value.toJS,
          List<double>() => value.toJSArray((e) => e.toJS),
          int() => value.toJS,
          List<int>() => value.toJSArray((e) => e.toJS),
          String() => value.toJS,
          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,
      );