# Get started

Canonical page: https://docs.ovok.com/flutter-sdk/getting-started

The SDK requires Dart 3.6 or later. Flutter apps can use `ovok_flutter`, which re-exports
the same `Ovok` client from `ovok_sdk`. Dart-only apps can depend on `ovok_sdk` alone.

## Install [#install]

```bash
flutter pub add ovok_flutter
```

For Dart-only applications, add `ovok_sdk` instead:

```bash
dart pub add ovok_sdk
```

Development builds (`0.1.0-dev.<N>+<sha7>`) and release candidates (`0.1.0-rc.<n>`)
are pre-releases on pub.dev, so they are never picked by default. Pin one to try it:

```bash
flutter pub add "ovok_flutter:0.1.0-dev.<N>+<sha7>"
```

## Create a client [#create-a-client]

The client keeps the session in a secure store you provide. `OvokSecureStore` has the
same `read`, `write` and `delete` methods as `flutter_secure_storage`, so an adapter
only forwards them:

```dart
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:ovok_flutter/ovok_flutter.dart';

class SecureStore implements OvokSecureStore {
  SecureStore(this._storage);

  final FlutterSecureStorage _storage;

  @override
  Future<String?> read({required String key}) => _storage.read(key: key);

  @override
  Future<void> write({required String key, required String value}) =>
      _storage.write(key: key, value: value);

  @override
  Future<void> delete({required String key}) => _storage.delete(key: key);
}

final ovok = Ovok(
  baseUrl: 'https://api.sandbox.ovok.com',
  tenantCode: 'your-tenant',
  secureStore: SecureStore(const FlutterSecureStorage(
    iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock),
  )),
);
```

`first_unlock` lets a background launch read the session after the device's first
unlock. A bad option throws `OvokConfigException` from the constructor, not from the
first request. Every option is described on [`Ovok`](/flutter-sdk/reference/ovok_sdk/ovok#ovoknew) in the API reference.

There is no `clientSecret`: anything shipped inside an app can be extracted, so the
SDK has no machine client.

## Sign in and read a resource [#sign-in-and-read-a-resource]

```dart
final result = await ovok.auth.login(
  profileType: ProfileType.practitioner,
  email: 'ada@example.com',
  password: password,
);

if (result case MfaRequired(:final challenge)) {
  await ovok.auth.verifyMfa(challenge, codeFromAuthenticatorApp);
}

final patient = await ovok.fhir.read('Patient', 'patient-id');
```

From here, see [Authentication](/flutter-sdk/authentication) for the rest of the session
lifecycle and [FHIR and paging](/flutter-sdk/fhir) for reading and writing data.
