start method

Future<void> start(
  1. String activityId,
  2. String activityType,
  3. Map<String, dynamic> contentState, {
  4. Map<String, dynamic>? attributes,
  5. Map<String, dynamic>? template,
})

Start a live activity locally. iOS → ActivityKit (NexusLiveActivityAttributes); Android → a Live Update. With a template (the same JSON the dashboard produces) contentState is the template's data: { step, state, progress, etaAt, values }. Also registers the instance so the server can update it.

Implementation

Future<void> start(
  String activityId,
  String activityType,
  Map<String, dynamic> contentState, {
  Map<String, dynamic>? attributes,
  Map<String, dynamic>? template,
}) async {
  if (_platform() == 'ios') {
    await NexusPlatform.instance.liveActivityStart(
      activityId: activityId,
      activityType: activityType,
      contentState: contentState,
      attributes: attributes,
      template: template,
    );
  } else if (_platform() == 'android') {
    if (template != null) _localTemplates[activityId] = template;
    await renderNexusLiveActivity({
      'event': 'start',
      'activityId': activityId,
      'template': ?template,
      if (template != null) 'data': contentState else 'contentState': contentState,
    });
    await registerActivity(activityId: activityId, activityType: activityType, platform: 'android', contentState: contentState);
  }
}