OptionSetting constructor

OptionSetting({
  1. required String name,
  2. required OptionType type,
  3. Object? value,
})

Implementation

OptionSetting({
  /// Name of the option to set.
  required String name,

  /// Type of the option.  The requested type must match the real type of the
  /// underlying option.
  required OptionType type,

  /// Value to set.  Leave unset to request automatic setting for options that
  /// have `autoSettable` enabled.  The type supplied for
  /// `value` must match `type`.
  Object? value,
}) : _wrapped = $js.OptionSetting(
        name: name,
        type: type.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')
        },
      );