PatchbayKeepAwakeDelegate typedef

PatchbayKeepAwakeDelegate = FutureOr<void> Function(bool enabled)

The consumer-owned hook that actually holds the screen awake.

Patchbay's four packages are pure Dart and pure Flutter; none of them may reach a platform channel, and adding a plugin — or a third-party wakelock dependency — to patchbay_flutter would change what every consumer's build links against just to gain a debugging switch. So the framework owns the protocol, the bookkeeping and the lease, and the App owns the one line that touches the platform:

// Android: FLAG_KEEP_SCREEN_ON, iOS: UIApplication.isIdleTimerDisabled.
PatchbayFlutterBridge(
  gates: gates,
  keepAwakeDelegate: (bool enabled) => myPlatformChannel.setKeepAwake(enabled),
);

The delegate is called with true to engage and false to release, never twice in a row with the same value: the bridge tracks the state and only calls on an actual transition. Throwing is a legitimate answer — the invocation is refused with keepAwakeDelegateFailed rather than recorded as a hold that never happened.

Implementation

typedef PatchbayKeepAwakeDelegate = FutureOr<void> Function(bool enabled);