# Flutter SDK examples

> What a Flutter app receives from made-up checkups: whole and partial results, a scope, and errors.

What a Flutter app receives from a face video checkup, with the package `youth_sdk_face_video`
0.6.0. The people and their values are made up: they show the shape of a
result, not what is healthy, and no value here is a reference.

`onFinalResults` receives a `List<YouthDataPoint>`, not JSON. Each list below writes those objects
as JSON with their `code`, `name`, `value` and `unit`: `unit` is the `YouthBioUnitType`'s `unit`
label. A number can arrive as an `int` or a `double`, so read it as `num`, never `int`; a `status`
value is a `String`. The list comes in no set order. [Results](/docs/sdks/results) says what each
field holds and how to read it.

Every point also carries the fields the lists leave out: `type`, deprecated, which is its `code`
but for a few older codes; `model`, `face_video_1`, the id of face video model 1; and
`modelVersion`, `2026.11` in this release. Up to five of them, `heart_rate`, `breathing_rate`,
`hrv_sdnn`, `hrv_mean_rri` and `pulse_respiration_quotient`, also carry a `confidence`, `low`,
`medium` or `high`; the others carry none. See [results](/docs/sdks/flutter/reference#results).

## A whole profile

The person:

```dart
const person = UserScanInformation(
  age: 46,
  weight: 72.5,
  height: 178.0,
  gender: Gender.male,
  smokingState: SmokingState.nonSmoker,
  ethnicity: Ethnicity.white,
);
```

After a whole measurement, `onFinalResults` receives 35 biomarkers:

```json
[
  { "code": "heart_rate", "name": "Heart Rate", "value": 64, "unit": "bpm" },
  {
    "code": "blood_pressure_systolic",
    "name": "Blood Pressure - Systolic",
    "value": 118,
    "unit": "mmHg"
  },
  {
    "code": "blood_pressure_diastolic",
    "name": "Blood Pressure - Diastolic",
    "value": 76,
    "unit": "mmHg"
  },
  { "code": "pulse_pressure", "name": "Pulse Pressure", "value": 42, "unit": "num" },
  {
    "code": "mean_arterial_pressure",
    "name": "Mean Arterial Pressure",
    "value": 90,
    "unit": "num"
  },
  { "code": "breathing_rate", "name": "Breathing rate", "value": 15, "unit": "bpm" },
  { "code": "oxygen_saturation", "name": "Oxygen saturation", "value": 97, "unit": "%" },
  {
    "code": "pulse_respiration_quotient",
    "name": "Pulse Respiratory Quotient (PRQ)",
    "value": 4.3,
    "unit": "num"
  },
  { "code": "hrv_sdnn", "name": "HRV SDNN", "value": 48, "unit": "ms" },
  { "code": "hrv_rmssd", "name": "RMSSD", "value": 36, "unit": "ms" },
  { "code": "hrv_mean_rri", "name": "Mean RRi", "value": 938, "unit": "ms" },
  { "code": "hrv_sd1", "name": "SD1", "value": 25, "unit": "ms" },
  { "code": "hrv_sd2", "name": "SD2", "value": 63, "unit": "ms" },
  { "code": "hrv_lf_hf", "name": "LF/HF", "value": 2.418, "unit": "num" },
  { "code": "stress_index", "name": "Stress Index", "value": 96, "unit": "num" },
  {
    "code": "normalized_stress_index",
    "name": "Normalized Stress Index",
    "value": 19,
    "unit": "%"
  },
  { "code": "stress_level", "name": "Stress Level", "value": "normal", "unit": "status" },
  { "code": "stress_response", "name": "Stress response", "value": "low", "unit": "status" },
  {
    "code": "recovery_ability",
    "name": "Recovery Ability / Energy",
    "value": "medium",
    "unit": "status"
  },
  { "code": "sns_index", "name": "SNS Index", "value": -0.4, "unit": "num" },
  { "code": "pns_index", "name": "PNS index", "value": 0.3, "unit": "num" },
  { "code": "hemoglobin", "name": "Hemoglobin", "value": 14.6, "unit": "g/dL" },
  { "code": "hemoglobin_index", "name": "Hemoglobin Index", "value": "normal", "unit": "status" },
  { "code": "hba1c", "name": "Average glucose index", "value": 5.21, "unit": "%" },
  { "code": "hba1c_estimate", "name": "HbA1c Estimate", "value": 5.21, "unit": "%" },
  { "code": "high_hba1c_risk", "name": "Metabolic index", "value": "low", "unit": "status" },
  {
    "code": "high_fasting_glucose_risk",
    "name": "High Fasting Glucose Risk",
    "value": "low",
    "unit": "status"
  },
  {
    "code": "high_total_cholesterol_risk",
    "name": "High Total Cholesterol Risk",
    "value": "medium",
    "unit": "status"
  },
  {
    "code": "low_hemoglobin_risk",
    "name": "Low Hemoglobin Risk",
    "value": "low",
    "unit": "status"
  },
  { "code": "hypertension_risk", "name": "Hypertension Risk", "value": "low", "unit": "status" },
  { "code": "cardiorespiratory_wellness", "name": "Wellness Index", "value": 8, "unit": "num" },
  {
    "code": "cardiorespiratory_wellness_level",
    "name": "Wellness Level",
    "value": "high",
    "unit": "status"
  },
  { "code": "ascvd_risk", "name": "ASCVD Risk", "value": 4.0, "unit": "%" },
  { "code": "ascvd_risk_level", "name": "Ascvd Risk Level", "value": "low", "unit": "status" },
  { "code": "heart_age", "name": "Heart Age", "value": 44, "unit": "year" }
]
```

## Only the biomarkers you use

Started with a scope, the same measurement gives only what the scope lists:

```dart
await YouthSdk().init(
  apiKey: apiKey,
  biomarkerScope: const YouthBiomarkerScope([
    YouthBioType.hba1cEstimate,
    YouthBioType.highTotalCholesterolRisk,
  ]),
);
```

```json
[
  { "code": "hba1c_estimate", "name": "HbA1c Estimate", "value": 5.21, "unit": "%" },
  {
    "code": "high_total_cholesterol_risk",
    "name": "High Total Cholesterol Risk",
    "value": "medium",
    "unit": "status"
  }
]
```

A biomarker in the scope that the measurement did not give is missing from the list, as without a
scope.

## Part of a profile

`ascvd_risk`, `ascvd_risk_level` and `heart_age` are worked out from the profile as well as the
measurement. Send the whole profile, `age`, `weight`, `height`, `gender` and `smokingState`, to get
them. This person has no smoking state:

```dart
const person = UserScanInformation(
  age: 34,
  weight: 58.0,
  height: 165.0,
  gender: Gender.female,
  ethnicity: Ethnicity.asian,
);
```

`onFinalResults` receives 32 biomarkers, without those three:

```json
[
  { "code": "heart_rate", "name": "Heart Rate", "value": 72, "unit": "bpm" },
  {
    "code": "blood_pressure_systolic",
    "name": "Blood Pressure - Systolic",
    "value": 111,
    "unit": "mmHg"
  },
  {
    "code": "blood_pressure_diastolic",
    "name": "Blood Pressure - Diastolic",
    "value": 72,
    "unit": "mmHg"
  },
  { "code": "pulse_pressure", "name": "Pulse Pressure", "value": 39, "unit": "num" },
  {
    "code": "mean_arterial_pressure",
    "name": "Mean Arterial Pressure",
    "value": 85,
    "unit": "num"
  },
  { "code": "breathing_rate", "name": "Breathing rate", "value": 16, "unit": "bpm" },
  { "code": "oxygen_saturation", "name": "Oxygen saturation", "value": 98, "unit": "%" },
  {
    "code": "pulse_respiration_quotient",
    "name": "Pulse Respiratory Quotient (PRQ)",
    "value": 4.5,
    "unit": "num"
  },
  { "code": "hrv_sdnn", "name": "HRV SDNN", "value": 52, "unit": "ms" },
  { "code": "hrv_rmssd", "name": "RMSSD", "value": 42, "unit": "ms" },
  { "code": "hrv_mean_rri", "name": "Mean RRi", "value": 833, "unit": "ms" },
  { "code": "hrv_sd1", "name": "SD1", "value": 30, "unit": "ms" },
  { "code": "hrv_sd2", "name": "SD2", "value": 67, "unit": "ms" },
  { "code": "hrv_lf_hf", "name": "LF/HF", "value": 1.62, "unit": "num" },
  { "code": "stress_index", "name": "Stress Index", "value": 85, "unit": "num" },
  {
    "code": "normalized_stress_index",
    "name": "Normalized Stress Index",
    "value": 17,
    "unit": "%"
  },
  { "code": "stress_level", "name": "Stress Level", "value": "normal", "unit": "status" },
  { "code": "stress_response", "name": "Stress response", "value": "low", "unit": "status" },
  {
    "code": "recovery_ability",
    "name": "Recovery Ability / Energy",
    "value": "high",
    "unit": "status"
  },
  { "code": "sns_index", "name": "SNS Index", "value": -0.6, "unit": "num" },
  { "code": "pns_index", "name": "PNS index", "value": 0.8, "unit": "num" },
  { "code": "hemoglobin", "name": "Hemoglobin", "value": 13.1, "unit": "g/dL" },
  { "code": "hemoglobin_index", "name": "Hemoglobin Index", "value": "normal", "unit": "status" },
  { "code": "hba1c", "name": "Average glucose index", "value": 5.3, "unit": "%" },
  { "code": "hba1c_estimate", "name": "HbA1c Estimate", "value": 5.3, "unit": "%" },
  { "code": "high_hba1c_risk", "name": "Metabolic index", "value": "low", "unit": "status" },
  {
    "code": "high_fasting_glucose_risk",
    "name": "High Fasting Glucose Risk",
    "value": "low",
    "unit": "status"
  },
  {
    "code": "high_total_cholesterol_risk",
    "name": "High Total Cholesterol Risk",
    "value": "low",
    "unit": "status"
  },
  {
    "code": "low_hemoglobin_risk",
    "name": "Low Hemoglobin Risk",
    "value": "low",
    "unit": "status"
  },
  { "code": "hypertension_risk", "name": "Hypertension Risk", "value": "low", "unit": "status" },
  { "code": "cardiorespiratory_wellness", "name": "Wellness Index", "value": 9, "unit": "num" },
  {
    "code": "cardiorespiratory_wellness_level",
    "name": "Wellness Level",
    "value": "high",
    "unit": "status"
  }
]
```

## A measurement that gave less

When a measurement cannot work out some biomarkers, they are missing from the list, and the rest
arrive as usual, with no error. Which ones go missing changes from one measurement to the next.
Blood pressure, for example, can fail to work out while the rest succeeds: the list then has no
`blood_pressure_systolic` and no `blood_pressure_diastolic`. Show what arrived.

## A measurement that failed

A measurement that fails sends no result: `onFinalResults` is not called, and `onError` receives a
`YouthVideoErrorData`. Here no face was in the frame for seven seconds before the measurement
began:

```dart
YouthVideoErrorData(
  code: 1,
  message: 'Your face was not detected for the minimum time required to start measuring. Please try again',
)
```

And here the person moved during the measurement:

```dart
YouthVideoErrorData(
  code: 3003,
  message: 'Keep your face still during the measurement and follow the instructions on the screen for an accurate result.',
)
```

The `message` is in the person's language, and you can show it to them. The screen is then ready
for the next measurement.

## At the monthly limit

The screen loads as usual. When the person presses record, the measurement is refused:

```dart
YouthVideoErrorData(
  code: 2003,
  message: "This checkup isn't available right now. Try again later or contact the app's support.",
)
```

## A measurement that cannot load

These stop the checkup before the person can start. The person did not allow the camera:

```dart
YouthVideoErrorData(
  code: 1005,
  message: 'You should access the device settings and grant the application permission to use the camera.',
)
```

The phone is in Low Power Mode:

```dart
YouthVideoErrorData(
  code: 4,
  message: "You should open the device settings and turn off 'Low Power Mode' or charge your device until the 'Low Power Mode' turns off.",
)
```

The measurement could not be activated: no connection, a wrong clock, or a full phone:

```dart
YouthVideoErrorData(
  code: 2004,
  message: 'You should take the following actions: Check the internet connection. Set the device time correctly. Verify that the device has sufficient storage.',
)
```

## A profile the measurement cannot accept

The checkup is for adults: check the age in your app before you show it. Here the first person above
was sent with an `age` of 16, and the measurement failed before it started:

```dart
YouthVideoErrorData(
  code: 7008,
  message: 'The age must be between 18 and 110. Correct it, or leave it empty.',
)
```

The [reference](/docs/sdks/flutter/reference#the-person) gives the ranges, and its
[errors](/docs/sdks/flutter/reference#errors) what each code means.
