# Health import

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

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

## HealthImportAccessStatus [#healthimportaccessstatus]

```dart
enum HealthImportAccessStatus
```

Health-source access state for one data type.

### Values [#values]

#### HealthImportAccessStatus.authorized [#healthimportaccessstatusauthorized]

```dart
static const HealthImportAccessStatus authorized
```

The app can read this data type.

#### HealthImportAccessStatus.shouldRequest [#healthimportaccessstatusshouldrequest]

```dart
static const HealthImportAccessStatus shouldRequest
```

The app can request access to this data type.

#### HealthImportAccessStatus.refused [#healthimportaccessstatusrefused]

```dart
static const HealthImportAccessStatus refused
```

The user did not grant access to this data type.

#### HealthImportAccessStatus.unsupported [#healthimportaccessstatusunsupported]

```dart
static const HealthImportAccessStatus unsupported
```

The active health source does not provide this data type.


## HealthImportAdapter [#healthimportadapter]

```dart
abstract interface class HealthImportAdapter<TType>
```

Reads and requests access to one health data type.

### Methods [#methods]

#### HealthImportAdapter.getStatus [#healthimportadaptergetstatus]

```dart
Future<HealthImportAccessStatus> getStatus(TType type)
```

Returns the current access status of `type`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `type` | `TType` | positional |  |

Returns `Future<HealthImportAccessStatus>`.

#### HealthImportAdapter.request [#healthimportadapterrequest]

```dart
Future<void> request(List<TType> types, {required bool background})
```

Requests access to `types`, optionally including background reading.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `types` | `List<TType>` | positional |  |
| `background` | `bool` | required named |  |

Returns `Future<void>`.


## HealthImportController [#healthimportcontroller]

```dart
class HealthImportController<TType> extends ChangeNotifier
```

Tracks health import access and requests permission when import is enabled.

### Constructors [#constructors]

#### HealthImportController.new [#healthimportcontrollernew]

```dart
HealthImportController<TType>({
  required Iterable<TType> types,
  required HealthImportAdapter<TType> adapter,
  bool background = false,
})
```

Creates a controller for [`types`](#healthimportcontrollertypes) using `adapter`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `types` | `Iterable<TType>` | required named |  |
| `adapter` | `HealthImportAdapter<TType>` | required named |  |
| `background` | `bool` | named | `false` |

### Properties [#properties]

#### HealthImportController.types [#healthimportcontrollertypes]

```dart
final List<TType> types
```

Data types managed by this controller.

#### HealthImportController.background [#healthimportcontrollerbackground]

```dart
final bool background
```

Whether the health source should allow reading data in the background.

#### HealthImportController.enabled [#healthimportcontrollerenabled]

```dart
bool get enabled
```

Whether health import is switched on.

#### HealthImportController.statusByType [#healthimportcontrollerstatusbytype]

```dart
Map<TType, HealthImportAccessStatus> get statusByType
```

Access status for each type whose status was read successfully.

#### HealthImportController.notShared [#healthimportcontrollernotshared]

```dart
List<TType> get notShared
```

Data types that the user has not shared.

#### HealthImportController.error [#healthimportcontrollererror]

```dart
Object? get error
```

Error from the last status check or access request.

### Methods [#methods-1]

#### HealthImportController.refresh [#healthimportcontrollerrefresh]

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

Refreshes access status for all configured types.

Returns `Future<void>`.

#### HealthImportController.setEnabled [#healthimportcontrollersetenabled]

```dart
Future<void> setEnabled(bool enabled)
```

Requests access before switching import on; switches off without a request.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `enabled` | `bool` | positional |  |

Returns `Future<void>`.
