Overview
The Synheart Focus Dart/Flutter SDK provides real-time cognitive load inference from biosignals for cross-platform mobile applications.Installation
Add topubspec.yaml:
Requirements
- Flutter >= 3.10.0
- Dart >= 3.0.0
Quick Start
Basic Usage
Real-Time Integration
Supported Focus States
The library supports four cognitive state categories:- 🎯 Focused: Optimal cognitive state, high attention and productivity (Score: 70-100)
- 😴 Bored: Low engagement, reduced attention (Score: 30-50)
- 😰 Anxious: Heightened arousal, reduced efficiency (Score: 20-40)
- 🔥 Overload: Cognitive overload, information processing difficulty (Score: 0-20)
API Reference
FocusEngine
Methods:
| Method | Description | Returns |
|---|---|---|
FocusEngine(config) | Create engine with config | FocusEngine |
initialize({modelPath, backend}) | Load ONNX model | Future<void> |
inferFromHrData({hrBpm, timestamp}) | Push HR data and infer | Future<FocusResult?> |
inferFromRrIntervals({rrIntervalsMs, hrMean, motionMagnitude}) | Infer from RR intervals | Future<FocusResult?> |
infer(hsiData, behaviorData) | Legacy: infer from HSI + behavior | Future<FocusState> |
onUpdate | Stream of focus updates | Stream<FocusState> |
reset() | Reset engine state | void |
dispose() | Dispose resources | void |
FocusConfig
Parameters:
| Parameter | Type | Default |
|---|---|---|
windowSeconds | int | 60 |
stepSeconds | int | 5 |
minRrCount | int | 30 |
enableSmoothing | bool | true |
smoothingLambda | double | 0.9 |
enableArtifactDetection | bool | true |
motionThreshold | double | 2.0 |
enableDebugLogging | bool | false |
FocusResult
Properties:
| Property | Type | Description |
|---|---|---|
focusState | String | Detected state: “Focused”, “Bored”, “Anxious”, or “Overload” |
focusScore | double | Focus score (0-100) |
confidence | double | Confidence (0-1) |
probabilities | Map<String, double> | All 4 class probabilities |
features | Map<String, double> | All 24 HRV features |
timestamp | DateTime | When inferred |
model | Map<String, dynamic> | Model metadata |
- Time Domain (9): mean_rr, std_rr, min_rr, max_rr, range_rr, rmssd, sdnn, nn50, pnn50
- Frequency Domain (11): VLF, LF, HF, UHF powers, total_power, lf_hf_ratio, normalized powers
- Statistical (4): skewness, kurtosis, median_rr, iqr
Resources
- pub.dev: synheart_focus
- Repository: synheart-focus-dart
- Full README: View on GitHub
Author: Synheart AI Team