1. SDKs
  2. Flutter

Please check our sample app, that makes full use of the SDK.

1. Introduction

The Vital SDK is split into three main components: vital_core, vital_health and vital_devices.

  • [vital_core][1] holds common components to both vital_health and vital_devices. Among other things, it has the network layer that allows us to send data from a device to a server.
  • [vital_health][2] is an abstraction over HealthKit an Health Connect(coming soon)
  • [vital_devices][3] is an abstraction over a set of Bluetooth devices.

2. Vital Core

Initialise client with region, environment and api key

final client = VitalClient()
  ..init(region: Region.eu, environment: Environment.sandbox, apiKey: 'sk_eu_...');

Query users:

final Response<List<User>> usersResponse = client.userService.getAll();

Link data provider:

client.linkProvider(user, 'strava','vitalexample: //callback');

Note: To return back to the app after successful linking, setup an intent filter in AndroidManifest.xml and custom URL scheme in info.plist. Note 2: Refer to documentation for all supported data providers.

3. Vital Health

1. Setup ios

Please read the iOS SDK instructions on Apple HealthKit. You need to edit your Capababilities and the Info.plist file.

First create your client:

final HealthkitServices healthkitServices = HealthkitServices(
  apiKey: apiKey,
  region: region,
  environment: Environment.sandbox,
)

You can then configure it:

await healthkitServices.configureClient();

await healthkitServices.configureHealthkit(backgroundDeliveryEnabled: true);

And set the userId:

await client.healthkitServices.setUserId('eba7c0a2-dc01-49f5-a361-...);

2. Using the SDK

You need to ask for permissions before getting data. For example the following allows you to read and write water:

final List<HealthkitResource> readResources = [HealthkitResource.water];
final List<HealthkitResourceWrite> writeResources = [
    HealthkitResourceWrite.water,
  ];

client.healthkitServices.ask(readResources, writeResources);

And syncing data:

client.healthkitServices.syncData();

You can also write data:

client.healthkitServices.writeHealthKitData(HealthkitResourceWrite.water, startDate, endDate, 1000);

Finally, observe the status stream, so you can react to changes:

Stream<SyncStatus> status = client.healthkitServices.status;

4. Setup android

Coming soon.

4. Vital Devices

1. Getting Started

1. iOS

Add the following to your Info.plist file:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>Our app uses bluetooth to find, connect and transfer data between different devices</string>

You will have to request the bluetooth permission in your app before using the SDK.

2. Android

Add the following to your AndroidManifest.xml:

<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>

        <!-- Request legacy Bluetooth permissions on older devices. -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>

You will have to request the appropriate permissions at in your app before you can call the Vital Devices SDK.

2. Usage

First you have to scan for one of the supported devices. You can find the list of supported devices by calling DeviceManager().devices.

 vitalDevices.scanForDevices(deviceModel).listen((device) {
    // now you have the device you were looking for
  });

Depending on the type of device you are connecting to, you will have to call different methods to connect to it.

1. Blood pressure monitor

  vitalDevices.readBloodPressureData(scannedDevice).listen((bloodPressureSamples) {
    // you will receive a list of blood pressure samples
  });

2. Glucose meter

  vitalDevices.readGlucoseMeterData(scannedDevice).listen((glucoseSamples) {
    // you will receive a list of glucose samples
  });

After you have received samples depending on the type of device you might need to star scanning again to receive the next set of samples.

5. Migrate from 0.3.* and 0.4.* to 0.5.*

Our original package vital_flutter is now separated into 3 packages: vital_core, vital_health and vital_devices.

  • vital_core contains the Vital Client
  • vital_health contains the Apple Health sync
  • vital_devices contains the sdk for bluetooth devices

vital_health and vital_devices are dependent vital_core.

To migrate you will need to add the new plugins you need in your pubspec.yaml file:

dependencies:
  flutter:
    sdk: flutter
  vital_core: ^latest_version
  vital_health: ^latest_version
  vital_devices: ^latest_version

All the imports have to be updated too. As an example: import 'package:vital_flutter/services/data/user.dart';

needs to be changes import 'package:vital_core/services/data/user.dart';

You can get all the classes by using:

import 'package:vital_core/vital_core.dart';
import 'package:vital_devices/vital_devices.dart';
import 'package:vital_health/vital_health.dart';

Your IDE should offer the correct import after you have updated your pubspec.yaml

Important changes:

  • DeviceManager was moved out of the VitalClient to the vital_devices package
  • HealthkitServices is now in the vital_health package
  • VitalClient is now in vital_core package

[1] https://pub.dev/packages/vital_core

[2] https://pub.dev/packages/vital_health

[3] https://pub.dev/packages/vital_devices