setTrackingProfiles static method

Future<void> setTrackingProfiles(
  1. Map<TrackingProfile, Config> profiles, {
  2. TrackingProfile? initialProfile,
  3. List<TrackingProfileRule> rules = const [],
  4. bool enableAutomation = false,
})

Registers tracking profiles and optional automation rules.

Implementation

static Future<void> setTrackingProfiles(
  Map<TrackingProfile, Config> profiles, {
  TrackingProfile? initialProfile,
  List<TrackingProfileRule> rules = const [],
  bool enableAutomation = false,
}) async {
  _profileManager ??= TrackingProfileManager(
    applyConfig: LocusConfig.setConfig,
    events: LocusStreams.events,
  );
  _profileManager!
    ..setProfiles(profiles)
    ..setRules(rules);
  if (initialProfile != null) {
    await _profileManager!.setProfile(initialProfile);
  }
  if (enableAutomation) {
    _profileManager!.startAutomation();
  } else {
    _profileManager!.stopAutomation();
  }
}