Methods
- React Native
- Flutter
- Capacitor
Any call can also fail with
internalError (a bug), and every call fails with UNAVAILABLE on the Capacitor
web build (Errors).
One session at a time
There is no session object.start() creates the wrapper’s one session and starts it, and you call start()
again to retry.
- While the session runs,
start()rejects withinvalidUsage, so callstop()first. - A
start()that rejects keeps no session, so call it again once the cause is fixed. completedorfailedends the session, and the nextstart()begins a new one withoutstop(). Acancelledevent does not end it: the next reading starts by itself (how retries work).stop()releases the session. Stopped aftermeasurementComplete, it still delivers the outcome, then ends (Finalizing). Astart()before that outcome arrives supersedes the old session and drops its remaining events.setAutoStartEnabled(false)beforestart()holds that session, and the setting goes back totruewhen the session ends (Holding the start).activate,deviceSupportand camera permission are app-wide.
Events
Every key is always present, with
null for an absent optional. TypeScript names the payloads GuidanceEvent,
StartedEvent, PreviewEvent, HeartbeatEvent, CancelledEvent, MeasurementCompleteEvent, CompletedEvent
and FailedEvent, with the VitalsEvent union and VitalsEventPayload<Name>. Dart uses the same names for the
subclasses of the sealed VitalsEvent. What each event means: Events.
Types
- TypeScript
- Dart
VitalsResultis the Result JSON. TypeScript receives it as is incompleted. In Dart,toMap()writes it,VitalsResult.fromMapreads it back, and results compare by value.LivePreview:heartRateBpmisnulluntil there is a heart rate,rmssdMsuntil about 20 seconds in, andsignalLeveluntil the first scored preview. Each reading’s first preview followsstartedat once, withprogress0 and every other valuenull.
Errors
A rejection (TypeScript) or a thrownVitalsException (Dart) carries code and message. Match on code, the
message is informational. Methods lists what each call rejects with. The failed event’s error has
the same shape, with cameraUnavailable (the camera could not be opened, or stopped and could not be restored) or
internalError, and the session has ended. Dart maps a code the package does not know to unknown, and delivers
errors on NeurofitVitals.events as VitalsException too.
invalidUsage means a calling mistake in your app:
What to do about each code: Failures.
Reading flow (React Native and Flutter)
Both packages export the pre-built flow and its parts. Screens, options, theme and strings: Pre-built reading flow.
The camera preview and the building blocks may change in minor releases
(Building blocks).