flutterFlutter

Prerequisites

  1. Add terra_flutter_rtarrow-up-right to your pubspec.yaml:

dependencies:
  terra_flutter_rt: ^X.X.X
  1. iOS: In your Info.plist, add:

    • Privacy - Bluetooth Always Usage Description: Justification for BLE usage

    • Privacy - Motion Usage Description: Justification for motion sensor usage (required if streaming accelerometer, gyroscope, or step data from the phone's built-in sensors via Connection.apple)

  2. Android: Permissions are requested automatically by the SDK on initialization.

SDK Initialization

circle-info

Initialize the SDK every time the app is opened or brought into the foreground.

import 'package:terra_flutter_rt/terra_flutter_rt.dart';
import 'package:terra_flutter_rt/types.dart';

await TerraFlutterRt.init('YOUR_DEV_ID', 'YOUR_REFERENCE_ID');

Initializing a Connection

Register the device with Terra using an authentication token generated from your backend:

To generate the token, make the below call from your backend:

Device Scanning

Two approaches depending on your needs:

Option 1: Built-in scan widget

On Android, this shows a native device picker. On iOS, use the iOSScanView widget.

Option 2: Programmatic scan with callback

Discover devices one by one and connect manually:

Real-Time Data Streaming

Once a device is connected, start streaming data to your app via a callback:

To stream to Terra's server instead, see Your App → Terra.

Stop & Disconnect

WatchOS Integration

To stream data from an Apple Watch:

circle-info

The watchOS app itself must be written in native Swift using the Terra class from the TerraRTiOS framework. See the iOS WatchOS guide for the watch-side setup.

You can also control workout sessions on the watch from your Flutter app:

Last updated

Was this helpful?