Docs
Contact

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

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 sendsvoid YouthSdk().setLocale(Locale locale);const YouthBiomarkerScope(List<YouthBioType> biomarkers);
  • apiKey decides whether checkups are tests or live: see Keys. 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.
  • locale is the language of the checkups' texts. Without it, the checkups use the language your organization saved, 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 off when false. Left out, your organization's setting decides, and they are on unless it turns them off.
YouthInitStateWhat happened
successThe key was accepted: the checkups can run.
failInvalidApiKeyThe key was refused. Check it, and that checkups in an app are on for your organization.
failConnectionErrorThe SDK could not reach YOU(th). Check the connection.
failUnknownAnything 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

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. 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 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 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

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

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,});
MemberWhat it does
init()Loads the measurement. Call once, before start; after a load error, make a new controller.
canStartWhether 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.
stateThe YouthVideoState, as a ValueListenable.
warningThe current YouthVideoWarningData, or null.
pulseThe heart rate measured so far, in beats per minute.
progressFrom 0 to 1 while it measures, otherwise null.
faceWhere 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.

YouthFaceWhat it holds
boxThe face's box in the camera's image, each side from 0 to 1 of the image.
isValidWhether the face is placed well enough to measure. When it isn't, warning says why.
imageSizeThe 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.

YouthVideoStateWhat it means
initializationThe measurement is loading.
initializedIt is ready: the person can start.
processIt measures. This begins when the measurement does, not at the tap.
stoppedThe measurement was stopped.
completeIt 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.

YouthFaceVideoModelWhich model runs
Left outModel 1 when your key offers it and your app carries it, otherwise model 2
faceVideo1Model 1
faceVideo2Model 2
autoThe 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:

AgeHeight and weightethnicityModel
Over 80AnyAnyfaceVideo2
80 or less, or noneImplausibleAnyfaceVideo1
80 or less, or nonePlausible, or noneblack, africanAmericanfaceVideo2
80 or less, or nonePlausible, or noneunspecifiedfaceVideo2
80 or less, or nonePlausible, or nonewhite, hispanicLatino, nativeAmericanfaceVideo1
80 or less, or nonePlausible, or noneasianfaceVideo1

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.

FaceVideoWarningStateWhat the person should do
deviceNotAlignedHold the phone straight.
faceNotCenteredCentre their face in the frame.
faceTooFarCome closer.
invalidDeviceOrientationHold the phone upright.
invalidRecogniseFace the camera.
tiltedHeadKeep their head level.
unevenLightFind 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.

codeWhat happened, and what to do
1No face was in the frame for seven seconds before the measurement began. The person can start again.
1501The measurement did not start or finish in time. The person can start again.
3003, 3004, 3008, 3009The 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, 1005The 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, 14Low Power Mode is on, or the battery is low. Ask the person to charge the phone.
2003Your organization has reached the face video's monthly limit. The checkup works again once the limit is raised, or next month.
2018The monthly limit for this key was taken away while your app ran. Ask your YOU(th) contact to set it.
2010The key was revoked. Issue another.
2032The 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, 3006The connection failed, YOU(th) could not answer, or the phone's date and time are wrong. Check both, then try again.
7007, 7008, 7012The 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.
8, 7006The phone's system version is too old, or the device is not supported. Try another device.
7009An earlier measurement would not close, even after three tries. Offer to try again.
2039The SDK release is too old. Upgrade to the current release.
2002, 2007, 2017, 2034The measurement was not authorized. Tell your YOU(th) contact the code.
Any other, 0 includedThe 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 shows errors as your app receives them.

The voice checkups

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. 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:

const YouthVideoFrameTheme(progressBarColor: Color(0xFF2E7D32))
YouthVoiceStateWhat it means
idleReady for the first recording, and again after a result or an error.
recordingIt records one sample: six seconds for respiratory, 30 for mental.
needSecondRecordRespiratory only. The first sample is in: the person records the second.
uploadingIt uploads the recordings.
processingIt checks that the recordings are clear enough.
waitForResultsIt waits for the results.
failedIt 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.

codeWhat happened, and what to do
permissionDeniedThe person has not allowed the microphone. Ask them to allow it in Settings.
interruptedA call, another app or the app going to the background stopped the recording, or something unexpected failed.
tooQuietThe voice was too quiet. Ask the person to speak louder.
tooShortThe recording ended early.
alreadyRecordingA recording was started while one was under way.
invalidFormatThe device recorded audio the checkup cannot use. If it keeps happening, tell your YOU(th) contact.
failedThe recording failed for another reason, or the microphone did not start or stop within 10 seconds.
checkupCreateFailedThe checkup could not start: the connection failed, or YOU(th) refused it. A refusal means the monthly limit is reached or not set, the key was revoked, or the voice checkups are off for this key.
uploadFailedThe recordings could not be uploaded. Check the connection.
validationFailedThe 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.
resultsUnavailableThe 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

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.

MemberWhat it does
canStartRecordingWhether 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.
isRecordingWhether a sample is being recorded.
stateThe 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

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 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 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 says what each one measures and how to read them. onFinalResults can receive an empty list.

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.

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}
ClassWhat it holds
YouthBiomarkerScoreA 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
YouthScoreRangeA 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
YouthHealthAreaScoreA health area's code, such as cardiovascular, its score and its band
YouthOverallScoreThe 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.codeWhat happened
profileIncompleteThe person has no age from 18 to 120, or no gender of female or male. Nothing was asked: give both for the next checkup.
scoresUnavailableNo connection, no answer in time, or YOU(th)'s service refused or failed. The results stay valid.

Theme

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, then the checkup's own look. The theme has more fields, for the selfie checkup.

The body composition checkup

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 fieldWhat the checkup takes
ageWhole years, from 0, for a year of birth from 1900
genderGender.female or Gender.male
heightCentimetres, from 50 to 250
weightKilograms, 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.

YouthBodyCompositionStateWhat it means
capturingThe camera is on screen: the first state.
creatingCheckupIt makes the checkup.
uploadingIt uploads the video.
waitForResultsThe video is uploaded and counted: the analysis measures it.
successonFinalResults received the results.
failedIt failed; onError says why, and controller.error holds it.
idleThe checkup was closed.

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

codeWhat happened, and what to do
consentRequiredThe controller was made with consentAccepted: false. Nothing was captured: show your consent screen, then make a new controller.
userDataRequiredThe profile lacks a field or holds a value outside its range. Nothing was captured: make a new controller with the profile.
captureFailedThe camera screen could not record, or the video is larger than YOU(th) takes (32 MB). Take a new video.
checkupCreateFailedThe checkup could not start: the connection failed, or YOU(th) refused it. A refusal means the monthly limit 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.
uploadFailedThe video could not be uploaded: the connection failed, or the monthly limit is reached. The video is kept, and can be sent again.
analysisFailedThe analysis could not measure the video. The checkup still counts against the monthly limit: take a new video.
resultsUnavailableThe results did not arrive within four minutes, or YOU(th) refused to give them. Take a new video later.
failedSomething unexpected failed.
MemberWhat it does
stateThe current YouthBodyCompositionState, as a ValueListenable.
errorThe last error, while failed.
canReuploadWhether the video is kept to send again: after making the checkup or the upload failed, before it was counted.
isUploadingWhether 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.

Last updated