requestInput method

void requestInput({
  1. required String consumer,
  2. Bias? bias,
  3. ActiveState activeState = ActiveState.high,
  4. Set<SignalEdge> triggers = const {},
})

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 requestInput({
  required String consumer,
  Bias? bias,
  ActiveState activeState = ActiveState.high,
  Set<SignalEdge> triggers = const {},
}) {
  ArgumentError.checkNotNull(activeState, "activeState");
  ArgumentError.checkNotNull(triggers, "triggers");
  _checkSupportsBiasValue(bias);

  // we need to lock both info and ownership.
  if (_requested) {
    throw StateError("Can't request line because it is already requested.");
  }

  PlatformInterface.instance.requestLine(
    lineHandle: _lineHandle,
    consumer: consumer,
    direction: LineDirection.input,
    bias: bias,
    activeState: activeState,
    triggers: triggers,
  );

  _info = PlatformInterface.instance.getLineInfo(_lineHandle);

  _requested = true;
}