# Runtime

Canonical page: https://docs.ovok.com/flutter-sdk/reference/ovok_flutter/runtime

{/* Generated by scripts/generate_reference.dart; do not edit. */}

## BluetoothRuntime [#bluetoothruntime]

```dart
class BluetoothRuntime
```

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

### Constructors [#constructors]

#### BluetoothRuntime.new [#bluetoothruntimenew]

```dart
BluetoothRuntime(BluetoothRuntimeOptions options)
```

Creates a runtime from platform ports and matching device drivers.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `options` | `BluetoothRuntimeOptions` | positional |  |

### Methods [#methods]

#### BluetoothRuntime.getSnapshot [#bluetoothruntimegetsnapshot]

```dart
BluetoothSnapshot getSnapshot()
```

The current immutable runtime snapshot.

Returns `BluetoothSnapshot`.

#### BluetoothRuntime.subscribe [#bluetoothruntimesubscribe]

```dart
Stream<BluetoothSnapshot> subscribe()
```

Emits the current snapshot followed by every state change.

Returns `Stream<BluetoothSnapshot>`.

#### BluetoothRuntime.checkPermission [#bluetoothruntimecheckpermission]

```dart
Future<BluetoothPermission> checkPermission()
```

Reads Bluetooth permission without prompting.

Returns `Future<BluetoothPermission>`.

#### BluetoothRuntime.requestPermission [#bluetoothruntimerequestpermission]

```dart
Future<BluetoothPermission> requestPermission()
```

Prompts for Bluetooth permission when the operating system permits it.

Returns `Future<BluetoothPermission>`.

#### BluetoothRuntime.openPermissionSettings [#bluetoothruntimeopenpermissionsettings]

```dart
Future<void> openPermissionSettings()
```

Opens the app's system settings.

Returns `Future<void>`.

#### BluetoothRuntime.startScan [#bluetoothruntimestartscan]

```dart
Future<void> startScan()
```

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

Returns `Future<void>`.

#### BluetoothRuntime.stopScan [#bluetoothruntimestopscan]

```dart
void stopScan()
```

Stops scanning while leaving connected devices active.

Returns `void`.

#### BluetoothRuntime.connect [#bluetoothruntimeconnect]

```dart
Future<void> connect(String deviceId)
```

Connects to a supported device found by a scan.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `deviceId` | `String` | positional |  |

Returns `Future<void>`.

#### BluetoothRuntime.disconnect [#bluetoothruntimedisconnect]

```dart
Future<void> disconnect(String deviceId)
```

Disconnects a device and suspends automatic reconnects for this session.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `deviceId` | `String` | positional |  |

Returns `Future<void>`.

#### BluetoothRuntime.pair [#bluetoothruntimepair]

```dart
Future<void> pair(String deviceId)
```

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

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `deviceId` | `String` | positional |  |

Returns `Future<void>`.

#### BluetoothRuntime.forget [#bluetoothruntimeforget]

```dart
Future<void> forget(String deviceId)
```

Forgets a paired device and disconnects it.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `deviceId` | `String` | positional |  |

Returns `Future<void>`.

#### BluetoothRuntime.retrySaves [#bluetoothruntimeretrysaves]

```dart
Future<void> retrySaves()
```

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

Returns `Future<void>`.

#### BluetoothRuntime.dispose [#bluetoothruntimedispose]

```dart
Future<void> dispose()
```

Stops scanning and waits for every device to disconnect.

Returns `Future<void>`.


## BluetoothRuntimeOptions [#bluetoothruntimeoptions]

```dart
class BluetoothRuntimeOptions
```

Dependencies for a [`BluetoothRuntime`](#bluetoothruntime).

### Constructors [#constructors-1]

#### BluetoothRuntimeOptions.new [#bluetoothruntimeoptionsnew]

```dart
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.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `scanner` | `BluetoothScanner` | required named |  |
| `permissions` | `BluetoothPermissions` | required named |  |
| `sink` | `BluetoothReadingSink` | required named |  |
| `devices` | `Iterable<BluetoothDeviceSupport>` | required named |  |
| `resultPolicy` | `ResultPolicy?` | named |  |
| `pairedStorage` | `OvokSecureStore?` | named |  |

### Properties [#properties]

#### BluetoothRuntimeOptions.scanner [#bluetoothruntimeoptionsscanner]

```dart
final BluetoothScanner scanner
```

The BLE adapter.

#### BluetoothRuntimeOptions.permissions [#bluetoothruntimeoptionspermissions]

```dart
final BluetoothPermissions permissions
```

The operating system permission prompts.

#### BluetoothRuntimeOptions.sink [#bluetoothruntimeoptionssink]

```dart
final BluetoothReadingSink sink
```

Where device readings are saved.

#### BluetoothRuntimeOptions.devices [#bluetoothruntimeoptionsdevices]

```dart
final List<BluetoothDeviceSupport> devices
```

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

#### BluetoothRuntimeOptions.resultPolicy [#bluetoothruntimeoptionsresultpolicy]

```dart
final ResultPolicy? resultPolicy
```

Selects readings to save; defaults to every reading.

#### BluetoothRuntimeOptions.pairedStorage [#bluetoothruntimeoptionspairedstorage]

```dart
final OvokSecureStore? pairedStorage
```

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