The problem
Companion apps can become slow when they rebuild whole screens for
frequent device telemetry, eagerly load media, or run networking and
parsing on the UI isolate.
What this guide covers
This tutorial focuses on practical architecture and performance
engineering for production systems. The central principle is to measure
the complete pipeline, keep latency-sensitive work close to the
hardware, and make failure states visible to the operator.
Reference architecture
Native device event source → typed repository → throttled state stream →
small Flutter widgets. Separate device status, media gallery,
configuration, and background sync into independent feature boundaries.
Implementation plan
- Throttle telemetry to the rate the UI can meaningfully display; do not repaint for every sensor tick.
- Use immutable state and narrow selectors so only affected widgets rebuild.
- Paginate media and lazily decode thumbnails instead of loading full-resolution files into memory.
- Move CPU-heavy parsing, compression, or local indexing to isolates or native workers after profiling.
- Cache capability metadata and invalidate it when the connected device or SDK version changes.
Example
final status = deviceEvents\n .where((event) => event.isDisplayRelevant)\n .transform(throttleLatest(const Duration(milliseconds: 200)));\n\n// `throttleLatest` is illustrative: choose a stream operator from your\n// preferred reactive library or implement a tested equivalent.
The snippets are illustrative starting points, not drop-in integrations.
Match APIs and version requirements to the exact SDK, OS image, hardware
revision, and runtime in your project.
Performance checklist
- Measure end-to-end latency, not only one function or model invocation.
- Report p50 and p95/p99 latency alongside throughput, memory use, and dropped work.
- Bound queues and define what happens when consumers fall behind.
- Avoid repeated frame copies and expensive work on Flutter's UI isolate.
- Test sustained workloads after the device reaches thermal equilibrium.
- Keep UI state, device state, and robot state distinct.
- Add timeouts, cancellation, reconnection, and explicit stale-data indicators.
- Profile on the actual target hardware using a reproducible build.
Common pitfalls
- Do not throttle safety-critical alerts without product-specific analysis.
- Do not use
setStateat the root for high-frequency telemetry. - Measure on a physical target; emulator performance is not representative of wearable thermal and radio constraints.
Hands-on exercise
Use Flutter DevTools to record rebuild counts before and after
introducing selectors and a throttled telemetry stream.
Further reading
- Flutter performance best practices
- Flutter DevTools
- Android Developers
- NVIDIA Developer
- ROS 2 documentation
Useful Links
Website: www.v-modal.com
SDK Flutter: https://github.com/v-modal/vmodal_sdk_flutter
SDK Android: https://github.com/v-modal/vmodal_sdk_android
Discord: https://discord.gg/K72z28KUx
Top comments (0)