Runtime

Generated reference for ovok_flutter: runtime.

  • Stable unknown
  • Release candidate since 0.1.0-rc.4
  • Development since 0.1.0-dev.27+7d4ccf0

BluetoothRuntime

class BluetoothRuntime

Scans for supported devices, connects, reads measurements and saves each one.

Constructors

BluetoothRuntime.new

BluetoothRuntime(BluetoothRuntimeOptions options)

Creates a runtime from platform ports and matching device drivers.

ParameterTypeKindDefault
optionsBluetoothRuntimeOptionspositional

Methods

BluetoothRuntime.getSnapshot

BluetoothSnapshot getSnapshot()

The current immutable runtime snapshot.

Returns BluetoothSnapshot.

BluetoothRuntime.subscribe

Stream<BluetoothSnapshot> subscribe()

Emits the current snapshot followed by every state change.

Returns Stream<BluetoothSnapshot>.

BluetoothRuntime.checkPermission

Future<BluetoothPermission> checkPermission()

Reads Bluetooth permission without prompting.

Returns Future<BluetoothPermission>.

BluetoothRuntime.requestPermission

Future<BluetoothPermission> requestPermission()

Prompts for Bluetooth permission when the operating system permits it.

Returns Future<BluetoothPermission>.

BluetoothRuntime.openPermissionSettings

Future<void> openPermissionSettings()

Opens the app's system settings.

Returns Future<void>.

BluetoothRuntime.startScan

Future<void> startScan()

Requests permission if needed, then scans whenever Bluetooth is on.

Returns Future<void>.

BluetoothRuntime.stopScan

void stopScan()

Stops scanning while leaving connected devices active.

Returns void.

BluetoothRuntime.connect

Future<void> connect(String deviceId)

Connects to a supported device found by a scan.

ParameterTypeKindDefault
deviceIdStringpositional

Returns Future<void>.

BluetoothRuntime.disconnect

Future<void> disconnect(String deviceId)

Disconnects a device and suspends automatic reconnects for this session.

ParameterTypeKindDefault
deviceIdStringpositional

Returns Future<void>.

BluetoothRuntime.pair

Future<void> pair(String deviceId)

Remembers and connects to a device, including after later scans.

ParameterTypeKindDefault
deviceIdStringpositional

Returns Future<void>.

BluetoothRuntime.forget

Future<void> forget(String deviceId)

Forgets a paired device and disconnects it.

ParameterTypeKindDefault
deviceIdStringpositional

Returns Future<void>.

BluetoothRuntime.retrySaves

Future<void> retrySaves()

Retries failed saves and flushes the sink's offline queue.

Returns Future<void>.

BluetoothRuntime.dispose

Future<void> dispose()

Stops scanning and waits for every device to disconnect.

Returns Future<void>.

BluetoothRuntimeOptions

class BluetoothRuntimeOptions

Dependencies for a BluetoothRuntime.

Constructors

BluetoothRuntimeOptions.new

BluetoothRuntimeOptions({
  required BluetoothScanner scanner,
  required BluetoothPermissions permissions,
  required BluetoothReadingSink sink,
  required Iterable<BluetoothDeviceSupport> devices,
  ResultPolicy? resultPolicy,
  OvokSecureStore? pairedStorage,
})

Creates a runtime configuration from platform ports and device support.

ParameterTypeKindDefault
scannerBluetoothScannerrequired named
permissionsBluetoothPermissionsrequired named
sinkBluetoothReadingSinkrequired named
devicesIterable<BluetoothDeviceSupport>required named
resultPolicyResultPolicy?named
pairedStorageOvokSecureStore?named

Properties

BluetoothRuntimeOptions.scanner

final BluetoothScanner scanner

The BLE adapter.

BluetoothRuntimeOptions.permissions

final BluetoothPermissions permissions

The operating system permission prompts.

BluetoothRuntimeOptions.sink

final BluetoothReadingSink sink

Where device readings are saved.

BluetoothRuntimeOptions.devices

final List<BluetoothDeviceSupport> devices

The device drivers considered by the runtime, in match priority order.

BluetoothRuntimeOptions.resultPolicy

final ResultPolicy? resultPolicy

Selects readings to save; defaults to every reading.

BluetoothRuntimeOptions.pairedStorage

final OvokSecureStore? pairedStorage

Secure storage for paired device IDs; pairing lasts for this session if omitted.

Last updated on

On this page