initialiseEventService function

void initialiseEventService(
  1. AtClientImpl atClientInstance,
  2. GlobalKey<NavigatorState> navKeyFromMainApp, {
  3. required String mapKey,
  4. required String apiKey,
  5. dynamic rootDomain = 'root.atsign.wtf',
  6. dynamic rootPort = 64,
  7. dynamic streamAlternative(
    1. List<EventKeyLocationModel>
    )?,
  8. bool initLocation = true,
})

Function to initialise the package. Should be mandatorily called before accessing package functionalities.

mapKey is needed to access maps.

apiKey is needed to calculate ETA.

Steps to get mapKey/apiKey available in README.

initLocation pass this as false if location package is initialised outside, so it is not initialised more than once.

streamAlternative a function which will return updated lists of EventKeyLocationModel

Implementation

void initialiseEventService(
    AtClientImpl atClientInstance, GlobalKey<NavigatorState> navKeyFromMainApp,
    {required String mapKey,
    required String apiKey,
    rootDomain = 'root.atsign.wtf',
    rootPort = 64,
    dynamic Function(List<EventKeyLocationModel>)? streamAlternative,
    bool initLocation = true}) {
  /// initialise keys
  MixedConstants.setApiKey(apiKey);
  MixedConstants.setMapKey(mapKey);

  if (initLocation) {
    initializeLocationService(
        atClientInstance, atClientInstance.currentAtSign!, navKeyFromMainApp,
        apiKey: MixedConstants.API_KEY!, mapKey: MixedConstants.MAP_KEY!);
  }

  /// To have eta in events
  AtLocationFlutterPlugin(
    [],
    calculateETA: true,
  );

  AtEventNotificationListener().init(atClientInstance,
      atClientInstance.currentAtSign!, navKeyFromMainApp, rootDomain);

  EventKeyStreamService()
      .init(atClientInstance, streamAlternative: streamAlternative);
}