# Flutter SDK reference

> Every class, state, warning and error the Flutter SDK offers your app, and its theme.

What your app uses from the Flutter SDK's packages, at 0.6.0. Each package's library holds its checkup's classes and the SDK's core: `YouthSdk`,
the person, results, theme and errors. The face video checkup's classes come from
`package:youth_sdk_face_video/youth_sdk_face_video.dart`, the voice checkups' from
`package:youth_sdk_voice/youth_sdk_voice.dart`.

## Start

```dart
Future<YouthInitState> YouthSdk().init({
  required String apiKey,
  Locale? locale, // en, de, it or es
  YouthBiomarkerScope? biomarkerScope, // every biomarker when left out
  bool? diagnostics, // false turns the SDK's error reports off
});

Future<YouthInitState> YouthSdk().initWithSessionProvider(
  YouthSessionProvider sessionProvider, {
  Locale? locale,
  YouthBiomarkerScope? biomarkerScope,
  bool? diagnostics,
});

typedef YouthSessionProvider = Future<Map<String, Object?>> Function();

Map<String, Object?> YouthSdk().sessionRequest; // the body your backend sends

void YouthSdk().setLocale(Locale locale);

const YouthBiomarkerScope(List<YouthBioType> biomarkers);
```

- **`apiKey`** decides whether checkups are tests or live: see [Keys](/docs/sdks#what-you-need).
  `init` still accepts `env`, which is deprecated and ignored: leave it out.
- **`initWithSessionProvider`** starts the SDK with sessions your backend opens with your key, so
  the key never ships in your app. `sessionRequest` is the JSON body your backend sends with its
  request: see [Keep your key on your backend](/docs/sdks/flutter#keep-your-key-on-your-backend).
- **`locale`** is the language of the checkups' texts. Without it, the checkups use the language
  [your organization saved](/docs/sdks#your-organizations-settings), then English; a language the
  SDK does not have is English too. `setLocale` changes it later.
- **`biomarkerScope`** limits what every checkup's `onFinalResults` receives to the biomarkers it
  lists. A checkup that measures none of them ends with an empty list. `onRealtimeResults` is not
  filtered.
- **`diagnostics`** turns the [error reports](/docs/sdks/privacy#what-the-sdks-send) off when `false`.
  Left out, your organization's setting decides, and they are on unless it turns them off.

| `YouthInitState`      | What happened                                                                            |
| --------------------- | ---------------------------------------------------------------------------------------- |
| `success`             | The key was accepted: the checkups can run.                                              |
| `failInvalidApiKey`   | The key was refused. Check it, and that checkups in an app are on for your organization. |
| `failConnectionError` | The SDK could not reach YOU(th). Check the connection.                                   |
| `failUnknown`         | Anything else. Try again later.                                                          |

`YouthSdk()` is one instance for the whole app. Call `init` again to try again, or to change the
key.

## The person

```dart
const UserScanInformation({
  int? age, // years
  double? weight, // kilograms
  double? height, // centimetres
  Gender gender = Gender.unspecified, // female, male, unspecified
  SmokingState smokingState = SmokingState.unspecified, // smoker, nonSmoker, unspecified
  Ethnicity ethnicity = Ethnicity.unspecified,
});
```

`Ethnicity` is `asian`, `black`, `white`, `africanAmerican`, `hispanicLatino`, `nativeAmerican` or
`unspecified`. It is used only to choose the model, and only with
[`model: YouthFaceVideoModel.auto`](#the-face-video-model). `ascvd_risk`, `ascvd_risk_level` and `heart_age` come together, and only when all of
these hold: `gender` and `smokingState` are set, not `unspecified`; `age`, `weight` and `height` are
given; the age is 18 to 80 and the BMI from weight and height 15 to 50; and the measurement gave a
blood pressure, systolic 90 to 200 mmHg, and an HbA1c risk. When one is missing, all three are. The
voice checkups use only `age` and `gender`, and count a person without an age as 35 and without a
gender as male. The body composition checkup needs `age`, `gender`, `height` and `weight`, in
[its own ranges](#the-body-composition-checkup).

The checkup is for adults, 18 and over. Keep `age` from 18 to 110, `weight` from 40 to 200
kilograms and `height` from 130 to 230 centimetres. A value outside fails the face video
measurement before it starts, with [error](#errors) `7008` (age), `7007` (weight) or `7012`
(height), whose message names the accepted range. Check the values before you open the camera, and
leave out what you do not know.

## The checkup screen

```dart
const YouthVideoFrame({
  required UserScanInformation userInfo,
  required YouthVideoFrameTheme theme,
  YouthFaceVideoModel? model, // see the face video model
  required Function(YouthVideoState) onState,
  required Function(List<YouthDataPoint>) onFinalResults,
  Function(YouthDataPoint)? onRealtimeResults, // values as they are measured
  Function(YouthVideoWarningData?)? onWarning, // null once nothing is wrong
  Function(YouthVideoErrorData)? onError,
  void Function(YouthScores)? onFinalScores, // see scores
  void Function(YouthScoresError)? onScoresError,
});
```

The screen reads `model` once, when it is built: for another model, or to try again after an error
while it loads, show a new `YouthVideoFrame` with a new `key`. Given another `userInfo`, it starts
over for that person, and a measurement under way for the person before ends without results. A
measurement's results and scores go to the callbacks the screen had when it started. After
`onFinalResults`, or an error during the measurement, the screen is ready for the next
measurement.

## Your own screen

```dart
YouthVideoController({
  required UserScanInformation user,
  YouthFaceVideoModel? model, // see the face video model
  void Function(YouthVideoState)? onState,
  void Function(YouthVideoWarningData?)? onWarning,
  void Function(YouthDataPoint)? onRealtimeResults,
  void Function(List<YouthDataPoint>)? onFinalResults,
  void Function(YouthVideoErrorData)? onError,
  void Function(YouthScores)? onFinalScores, // see scores
  void Function(YouthScoresError)? onScoresError,
});
```

| Member      | What it does                                                                                 |
| ----------- | -------------------------------------------------------------------------------------------- |
| `init()`    | Loads the measurement. Call once, before `start`; after a load error, make a new controller. |
| `canStart`  | Whether `start` can begin a measurement now.                                                 |
| `start()`   | Starts a measurement.                                                                        |
| `stop()`    | Stops the measurement under way.                                                             |
| `dispose()` | Releases the camera. Call when the screen closes.                                            |
| `state`     | The `YouthVideoState`, as a `ValueListenable`.                                               |
| `warning`   | The current `YouthVideoWarningData`, or null.                                                |
| `pulse`     | The heart rate measured so far, in beats per minute.                                         |
| `progress`  | From 0 to 1 while it measures, otherwise null.                                               |
| `face`      | Where the face is in the camera's image, as a `YouthFace`, or null while no face is found.   |

`YouthVideoCameraView(controller: controller)` shows the controller's camera.

| `YouthFace`   | What it holds                                                                                            |
| ------------- | -------------------------------------------------------------------------------------------------------- |
| `box`         | The face's box in the camera's image, each side from 0 to 1 of the image.                                |
| `isValid`     | Whether the face is placed well enough to measure. When it isn't, `warning` says why.                    |
| `imageSize`   | The camera image's size in pixels.                                                                       |
| `boxIn(size)` | The box in a preview of `size`, cut as `YouthVideoCameraView` cuts the camera's image to fill its space. |

`face` is null on face video model 2, which draws its own face mask. See
[draw your own face guide](/docs/sdks/flutter#draw-your-own-face-guide).

| `YouthVideoState` | What it means                                                       |
| ----------------- | ------------------------------------------------------------------- |
| `initialization`  | The measurement is loading.                                         |
| `initialized`     | It is ready: the person can start.                                  |
| `process`         | It measures. This begins when the measurement does, not at the tap. |
| `stopped`         | The measurement was stopped.                                        |
| `complete`        | It ended; the results follow.                                       |

`YouthVideoState` also has `disposed`, which the SDK never sends: after `dispose`, no callback
arrives.

## The face video model

`model` on `YouthVideoFrame` and `YouthVideoController` names the face video model to run. YOU(th)
sets which models your key may run, separately for your test and live keys.

| `YouthFaceVideoModel` | Which model runs                                                           |
| --------------------- | -------------------------------------------------------------------------- |
| Left out              | Model 1 when your key offers it and your app carries it, otherwise model 2 |
| `faceVideo1`          | Model 1                                                                    |
| `faceVideo2`          | Model 2                                                                    |
| `auto`                | The model the person's profile suits, among those your key offers          |

A model your key does not offer, or whose package your app does not carry, is refused before the
camera starts, with error `2032`. `auto` chooses only among the models your key offers and your app
carries.

With `auto`, and only then, the profile chooses the model, by these rules in order:

| Age                 | Height and weight  | `ethnicity`                                 | Model        |
| ------------------- | ------------------ | ------------------------------------------- | ------------ |
| Over 80             | Any                | Any                                         | `faceVideo2` |
| 80 or less, or none | Implausible        | Any                                         | `faceVideo1` |
| 80 or less, or none | Plausible, or none | `black`, `africanAmerican`                  | `faceVideo2` |
| 80 or less, or none | Plausible, or none | `unspecified`                               | `faceVideo2` |
| 80 or less, or none | Plausible, or none | `white`, `hispanicLatino`, `nativeAmerican` | `faceVideo1` |
| 80 or less, or none | Plausible, or none | `asian`                                     | `faceVideo1` |

Implausible is a height outside 120 to 220 centimetres, a weight outside 30 to 200 kilograms, or a
BMI outside 15 to 45, checked only when both height and weight are given. `gender` is not used. When
your key offers only one of the two models, that one runs whatever the profile suits. These rules
may change in later releases, which can change the biomarkers a person receives: if your product
depends on a fixed set, name the model.

`selectedProvider` on `YouthVideoFrame` and `provider` on `YouthVideoController`, with
`FaceVideoScanProvider`, are deprecated and stay in 0.6.0: use `model`. `provider1` stands for
`faceVideo1` and `provider2` for `faceVideo2`.

## Warnings

While it measures, `YouthVideoWarningData` tells the person what to change: its `state`, and a
`message` in their language.

| `FaceVideoWarningState`    | What the person should do       |
| -------------------------- | ------------------------------- |
| `deviceNotAligned`         | Hold the phone straight.        |
| `faceNotCentered`          | Centre their face in the frame. |
| `faceTooFar`               | Come closer.                    |
| `invalidDeviceOrientation` | Hold the phone upright.         |
| `invalidRecognise`         | Face the camera.                |
| `tiltedHead`               | Keep their head level.          |
| `unevenLight`              | Find even light.                |

`FaceVideoWarningState` has other values, which this version never sends.

## Errors

`YouthVideoErrorData` carries a `code` and a `message`. The message is in the person's language and
written for them, so you can show it. The code tells your app what happened and what to do.

| `code`                                                                       | What happened, and what to do                                                                                                                                                                                                               |
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `1`                                                                          | No face was in the frame for seven seconds before the measurement began. The person can start again.                                                                                                                                        |
| `1501`                                                                       | The measurement did not start or finish in time. The person can start again.                                                                                                                                                                |
| `3003`, `3004`, `3008`, `3009`                                               | The measurement did not hold: the face moved or was lost, or the phone was too busy or too warm. The person can start again.                                                                                                                |
| `1001`, `1002`, `1005`                                                       | The camera cannot film at 640×480 and 30 frames a second, failed, or your app may not use it. Ask for the camera permission; otherwise try another device.                                                                                  |
| `4`, `14`                                                                    | Low Power Mode is on, or the battery is low. Ask the person to charge the phone.                                                                                                                                                            |
| `2003`                                                                       | Your organization has reached the face video's [monthly limit](/docs/sdks#monthly-limits). The checkup works again once the limit is raised, or next month.                                                                                 |
| `2018`                                                                       | The monthly limit for this key was taken away while your app ran. Ask your YOU(th) contact to set it.                                                                                                                                       |
| `2010`                                                                       | The key was revoked. Issue another.                                                                                                                                                                                                         |
| `2032`                                                                       | The checkup is not available for this key: no monthly limit is set, it is switched off, it is not on for apps, it is not served now, or the face video model you named is not offered for it or not in your app. Tell your YOU(th) contact. |
| `17`, `2004`, `2016`, `2024`, `2025`, `2036`, `2037`, `2038`, `2042`, `3006` | The connection failed, YOU(th) could not answer, or the phone's date and time are wrong. Check both, then try again.                                                                                                                        |
| `7007`, `7008`, `7012`                                                       | The profile's weight, age or height is outside what the measurement accepts, and the measurement does not start. The message names the accepted range. Correct the value, or leave it out. See [the person](#the-person).                   |
| `8`, `7006`                                                                  | The phone's system version is too old, or the device is not supported. Try another device.                                                                                                                                                  |
| `7009`                                                                       | An earlier measurement would not close, even after three tries. Offer to try again.                                                                                                                                                         |
| `2039`                                                                       | The SDK release is too old. Upgrade to the current release.                                                                                                                                                                                 |
| `2002`, `2007`, `2017`, `2034`                                               | The measurement was not authorized. Tell your YOU(th) contact the code.                                                                                                                                                                     |
| Any other, `0` included                                                      | The measurement could not load, start or finish. Offer to try again; if it keeps failing, tell your YOU(th) contact the code.                                                                                                               |

An error ends the measurement, and no result follows it. `0` arrives with the generic message, "Unknown error, try again later." [Flutter SDK examples](/docs/sdks/flutter/examples)
shows errors as your app receives them.

## The voice checkups

```dart
const YouthVoiceFrame({
  required UserScanInformation user,
  required YouthVideoFrameTheme theme,
  VoiceScanType type = VoiceScanType.respiratory,
  void Function(YouthVoiceState)? onState,
  void Function(List<YouthDataPoint>)? onFinalResults,
  void Function(YouthVoiceErrorData)? onError,
  void Function(YouthScores)? onFinalScores, // see scores
  void Function(YouthScoresError)? onScoresError,
});
```

`VoiceScanType` is `respiratory` or `mental`: see
[Run a voice checkup](/docs/sdks/flutter#run-a-voice-checkup). Given another `user`, the screen's
next checkup is for that person. A checkup under way keeps the person and the callbacks its first
recording started with, for its results and its scores.

Of the theme, the voice checkups use the footer's and the record button's colours,
`headerTextStyle` and `secondaryTextStyle`. The animation while the person records takes
`progressBarColor`, and stays orange when neither your code nor your organization's settings set
it:

```dart
const YouthVideoFrameTheme(progressBarColor: Color(0xFF2E7D32))
```

| `YouthVoiceState`  | What it means                                                            |
| ------------------ | ------------------------------------------------------------------------ |
| `idle`             | Ready for the first recording, and again after a result or an error.     |
| `recording`        | It records one sample: six seconds for respiratory, 30 for mental.       |
| `needSecondRecord` | Respiratory only. The first sample is in: the person records the second. |
| `uploading`        | It uploads the recordings.                                               |
| `processing`       | It checks that the recordings are clear enough.                          |
| `waitForResults`   | It waits for the results.                                                |
| `failed`           | It failed; `onError` says why.                                           |

`YouthVoiceState` also has `stopped`, `success` and `disposed`, which the SDK never sends.

`YouthVoiceErrorData` carries a `code`, a `YouthVoiceErrorCode`, and a `message` for the person, in
their language. After any error the recordings are discarded and the person starts again from the
first one.

| `code`                | What happened, and what to do                                                                                                                                                                                                     |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `permissionDenied`    | The person has not allowed the microphone. Ask them to allow it in Settings.                                                                                                                                                      |
| `interrupted`         | A call, another app or the app going to the background stopped the recording, or something unexpected failed.                                                                                                                     |
| `tooQuiet`            | The voice was too quiet. Ask the person to speak louder.                                                                                                                                                                          |
| `tooShort`            | The recording ended early.                                                                                                                                                                                                        |
| `alreadyRecording`    | A recording was started while one was under way.                                                                                                                                                                                  |
| `invalidFormat`       | The device recorded audio the checkup cannot use. If it keeps happening, tell your YOU(th) contact.                                                                                                                               |
| `failed`              | The recording failed for another reason, or the microphone did not start or stop within 10 seconds.                                                                                                                               |
| `checkupCreateFailed` | The checkup could not start: the connection failed, or YOU(th) refused it. A refusal means the [monthly limit](/docs/sdks#monthly-limits) is reached or not set, the key was revoked, or the voice checkups are off for this key. |
| `uploadFailed`        | The recordings could not be uploaded. Check the connection.                                                                                                                                                                       |
| `validationFailed`    | The recordings were not clear enough: a quiet room, one long "Aahh" or 30 seconds of speech. The checkup still counts against the monthly limit, and recording again counts again.                                                |
| `resultsUnavailable`  | The results did not arrive within two minutes, or YOU(th) refused to give them. Try again later.                                                                                                                                  |

`YouthVoiceErrorCode` also has `cancelled`, which the SDK never sends.

## Your own voice screen

```dart
YouthVoiceController.respiratory({
  required UserScanInformation user,
  void Function(YouthVoiceState)? onState,
  void Function(Duration elapsed, Duration total)? onProgress, // while it records
  void Function(List<YouthDataPoint>)? onFinalResults,
  void Function(YouthVoiceErrorData)? onError,
  void Function(YouthScores)? onFinalScores, // see scores
  void Function(YouthScoresError)? onScoresError,
});

YouthVoiceController.mental({ /* the same parameters */ });
```

In `onProgress`, `total` is six seconds for respiratory and 30 for mental, and `elapsed` starts
from zero for each sample.

| Member              | What it does                                                                                                                             |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `canStartRecording` | Whether `startRecording` can record now: in `idle` and `needSecondRecord`.                                                               |
| `startRecording()`  | Records the next sample. After the last (the second for respiratory, the only one for mental), the upload and the analysis follow alone. |
| `stopRecording()`   | Stops the recording under way and discards this checkup's recordings.                                                                    |
| `isRecording`       | Whether a sample is being recorded.                                                                                                      |
| `state`             | The current `YouthVoiceState`.                                                                                                           |
| `init()`            | Prepares the microphone. Optional: `startRecording` calls it.                                                                            |
| `dispose()`         | Releases the microphone and stops the checkup. Call when the screen closes.                                                              |

After `dispose`, no callback arrives and the controller cannot be used again.

## Results

```dart
class YouthDataPoint {
  final String code; // the biomarker's code in YOU(th)'s catalog, such as "heart_rate"
  final String type; // deprecated: an older code for 14 biomarkers, until 1.0
  final String name; // a name to show, in English
  final dynamic value; // an int or a double; for a status a String such as "low"
  final YouthBioUnitType unit;
  final String model; // the id of the model, such as face_video_1 or voice_1
  final String modelVersion; // such as 2026.11; unknown when the model did not say
  final YouthConfidence? confidence; // low, medium or high; null when the value has none
}
```

- **`model`** is the YOU(th) model that produced the value: `face_video_1`, `face_video_2`,
  `voice_1`, `face_selfie_1` or `body_composition_1`. A model's id never changes meaning.
- **`modelVersion`** is a date, `YYYY.MM`, with `.2` for a second change in one month. It changes
  whenever anything that can move a value changes: the engine behind the model, how its output is
  mapped, or units. A face video model runs on the device, so its version is fixed by the SDK
  release you ship and changes only when you upgrade; the release notes list every change. Voice,
  face selfie and body composition run on YOU(th)'s service: a change is announced at least 30 days before it takes
  effect, and the version in the results changes on that day. The service names the version in
  each result; a result it did not name carries `unknown`. `YouthSdk().sdkVersion` gives the SDK's
  own version.
- **`confidence`** is how sure the model is of the value. Face video model 1 gives one for five
  measurements: pulse rate (`heart_rate`), respiration rate (`breathing_rate`), SDNN (`hrv_sdnn`),
  mean RRI (`hrv_mean_rri`) and PRQ (`pulse_respiration_quotient`). Every other value has none, which says nothing about the
  measurement's quality: the [warnings](#warnings) during the measurement tell when it was taken
  in poor conditions.

Face video model 1 delivers only the biomarkers the SDK knows, in `onFinalResults` and in
`onRealtimeResults`. The raw beat-to-beat intervals are not delivered; their mean arrives as
`hrv_mean_rri`.

Match on `code`. `type` is the same but for 14 biomarkers, which it names by older codes until 1.0,
such as `diabetes_risk` for `high_hba1c_risk`: the [changelog](/docs/changelog) lists them. Face
video model 1 also sends its HbA1c estimate as `hba1c`, beside `hba1c_estimate`, and its hemoglobin
in g/dL as `hemoglobin`, beside its band, `hemoglobin_index`, until 1.0: show `hba1c_estimate` and
`hemoglobin_index`.

`YouthBioType` lists the biomarkers, each with its `code` and its `key`, the value of `type`. The
14 take the catalog's names, such as `YouthBioType.highHba1cRisk`; their old names, such as
`YouthBioType.diabetesRisk`, are the same values, and are deprecated. `YouthBioUnitType` lists the
units, each with its label in `unit`, such as `bpm`. [Results](/docs/sdks/results) says what each one measures and how
to read them. `onFinalResults` can receive an empty list.

```dart
String show(YouthDataPoint point) => switch (point.unit) {
  YouthBioUnitType.status || YouthBioUnitType.num || YouthBioUnitType.unknown => '${point.value}',
  _ => '${point.value} ${point.unit.unit}',
};
```

## Scores

Where your organization gets YOU(th)'s scores, `onFinalScores` receives them after
`onFinalResults`, or `onScoresError` says why there are none: see
[YOU(th)'s scores](/docs/sdks/flutter#youths-scores).

```dart
class YouthScores {
  final String version; // how the scores were made: it changes whenever a scoring rule does
  final List<YouthBiomarkerScore> biomarkers;
  final List<YouthHealthAreaScore> healthAreas;
  final YouthOverallScore? overall; // null when no health area that counts in it has a score
}
```

| Class                  | What it holds                                                                                                                                                                                                       |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `YouthBiomarkerScore`  | A biomarker's `code`, `blood_pressure` for both its sides; its `score`, from 0 to 1; its `band`, `strong`, `moderate` or `weak`; and its `ranges`, each band's values for this person                               |
| `YouthScoreRange`      | A band's values: from `lower`, included, to `upper`, left out, either one null where the band has no end; or its `category` for a status, such as `low`; for blood pressure, its `field`, `systolic` or `diastolic` |
| `YouthHealthAreaScore` | A health area's `code`, such as `cardiovascular`, its `score` and its `band`                                                                                                                                        |
| `YouthOverallScore`    | The overall `score` and `band`, of the health areas that count in it                                                                                                                                                |

A biomarker the scoring does not take, such as `heart_age`, has no score. Hemoglobin is scored as
`hemoglobin_index` and HbA1c as `hba1c_estimate`.

| `YouthScoresError.code` | What happened                                                                                                                    |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `profileIncomplete`     | The person has no `age` from 18 to 120, or no `gender` of `female` or `male`. Nothing was asked: give both for the next checkup. |
| `scoresUnavailable`     | No connection, no answer in time, or YOU(th)'s service refused or failed. The results stay valid.                                |

## Theme

```dart
const YouthVideoFrameTheme({
  Color? footerBgColor,
  Color? recordBtnColor,
  Color? recordBtnBorderColor,
  Color? progressBarColor, // the record button's progress ring, the voice recording animation
  TextStyle? headerTextStyle,
  TextStyle? headerErrorTextStyle,
  TextStyle? primaryTextStyle,
  TextStyle? secondaryTextStyle,
  TextStyle? warningTextStyle,
});
```

What you leave out takes [your organization's settings](/docs/sdks#your-organizations-settings),
then the checkup's own look. The theme has more fields, for the
[selfie checkup](/docs/sdks/flutter/selfie).

## The body composition checkup

```dart
YouthBodyCompositionController({
  required bool consentAccepted, // true once the person accepted your consent screen
  UserScanInformation user = const UserScanInformation(), // age, gender, height and weight: see below
  bool customUploadView = false, // true: nothing on screen after the capture, draw your own
  void Function(YouthBodyCompositionState)? onState,
  void Function(String step)? onCaptureStatus, // the capture's own steps, such as recording
  void Function(List<YouthDataPoint>)? onFinalResults,
  void Function(YouthBodyCompositionErrorData)? onError,
  void Function()? onClose, // the person left the capture, or close() was called
  void Function(YouthScores)? onFinalScores, // see scores
  void Function(YouthScoresError)? onScoresError,
});

const YouthBodyCompositionFrame({
  required YouthBodyCompositionController controller,
  YouthBodyCompositionTheme? theme,
  bool userReview = true, // the person reviews the video before it is sent
  bool skipIntroSteps = true, // Android only: starts at positioning
});
```

| `user` field | What the checkup takes                             |
| ------------ | -------------------------------------------------- |
| `age`        | Whole years, from 0, for a year of birth from 1900 |
| `gender`     | `Gender.female` or `Gender.male`                   |
| `height`     | Centimetres, from 50 to 250                        |
| `weight`     | Kilograms, from 20 to 500                          |

A profile outside these ends the checkup at once with `userDataRequired`, and so does a missing
field: the checkup never guesses one. `userId` is not used.

| `YouthBodyCompositionState` | What it means                                                   |
| --------------------------- | --------------------------------------------------------------- |
| `capturing`                 | The camera is on screen: the first state.                       |
| `creatingCheckup`           | It makes the checkup.                                           |
| `uploading`                 | It uploads the video.                                           |
| `waitForResults`            | The video is uploaded and counted: the analysis measures it.    |
| `success`                   | `onFinalResults` received the results.                          |
| `failed`                    | It failed; `onError` says why, and `controller.error` holds it. |
| `idle`                      | The checkup was closed.                                         |

`YouthBodyCompositionErrorData` carries a `code`, a `YouthBodyCompositionErrorCode`, and a
`message` for the person, in their language.

| `code`                | What happened, and what to do                                                                                                                                                                                                                                                   |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `consentRequired`     | The controller was made with `consentAccepted: false`. Nothing was captured: show your consent screen, then make a new controller.                                                                                                                                              |
| `userDataRequired`    | The profile lacks a field or holds a value outside its range. Nothing was captured: make a new controller with the profile.                                                                                                                                                     |
| `captureFailed`       | The camera screen could not record, or the video is larger than YOU(th) takes (32 MB). Take a new video.                                                                                                                                                                        |
| `checkupCreateFailed` | The checkup could not start: the connection failed, or YOU(th) refused it. A refusal means the [monthly limit](/docs/sdks#monthly-limits) is reached, or the key was revoked. A key without the checkup, its limit not set or the checkup off, ends it before the camera opens. |
| `uploadFailed`        | The video could not be uploaded: the connection failed, or the monthly limit is reached. The video is kept, and can be sent again.                                                                                                                                              |
| `analysisFailed`      | The analysis could not measure the video. The checkup still counts against the monthly limit: take a new video.                                                                                                                                                                 |
| `resultsUnavailable`  | The results did not arrive within four minutes, or YOU(th) refused to give them. Take a new video later.                                                                                                                                                                        |
| `failed`              | Something unexpected failed.                                                                                                                                                                                                                                                    |

| Member        | What it does                                                                                                                 |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `state`       | The current `YouthBodyCompositionState`, as a `ValueListenable`.                                                             |
| `error`       | The last error, while `failed`.                                                                                              |
| `canReupload` | Whether the video is kept to send again: after making the checkup or the upload failed, before it was counted.               |
| `isUploading` | Whether the checkup is past the camera and still running: in `creatingCheckup`, `uploading` or `waitForResults`.             |
| `reupload()`  | Sends the kept video again, to the same checkup, which is counted once; to a new one when YOU(th) no longer knows the first. |
| `reset()`     | Drops the video and opens the camera again. Does nothing after `consentRequired` or `userDataRequired`.                      |
| `close()`     | Ends the checkup and calls `onClose`.                                                                                        |
| `dispose()`   | Stops an upload or a wait, and deletes the video. Call when the screen closes; no callback arrives afterwards.               |

Without `customUploadView`, the frame's own screen shows the steps, the results' arrival, and the
error with the actions that can help. `YouthBodyCompositionTheme` sets its colours and the camera
screen's, as `YouthVideoFrameTheme` does for face video.
