requestOutput method

void requestOutput({
  1. required String consumer,
  2. OutputMode outputMode = OutputMode.pushPull,
  3. Bias? bias,
  4. ActiveState activeState = ActiveState.high,
  5. required bool initialValue,
})

Requests ownership of a GPIO line with the given configuration.

If FlutterGpiod.supportsBias is false, bias must be null, otherwise a UnsupportedError will be thrown.

Only a free line can be requested.

Implementation

void requestOutput({
  required String consumer,
  OutputMode outputMode = OutputMode.pushPull,
  Bias? bias,
  ActiveState activeState = ActiveState.high,
  required bool initialValue,
}) {
  ArgumentError.checkNotNull(outputMode, "outputMode");
  ArgumentError.checkNotNull(activeState, "activeState");
  ArgumentError.checkNotNull(initialValue, "initialValue");
  _checkSupportsBiasValue(bias);

  if (_requested) {
    throw StateError("Can't request line because it is already requested.");
  }

  PlatformInterface.instance.requestLine(
    lineHandle: _lineHandle,
    consumer: consumer,
    direction: LineDirection.output,
    outputMode: outputMode,
    bias: bias,
    activeState: activeState,
    initialValue: initialValue,
  );

  _info = PlatformInterface.instance.getLineInfo(_lineHandle);
  _value = initialValue;
  _requested = true;
}