initialiseEventService function
Future<void>
initialiseEventService(})
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
initLocation
if true, then location service will be initialised by the events package
if it is already initialsed outside this package, then pass false
,
make sure to not initialise the location package more than once.
Implementation
Future<void> initialiseEventService(GlobalKey<NavigatorState> navKeyFromMainApp,
{required String mapKey,
required String apiKey,
rootDomain = 'root.atsign.wtf',
rootPort = 64,
dynamic Function(List<EventKeyLocationModel>)? streamAlternative,
bool initLocation = true}) async {
/// initialise keys
MixedConstants.setApiKey(apiKey);
MixedConstants.setMapKey(mapKey);
SizeConfig().init(navKeyFromMainApp.currentState!.context);
if (initLocation) {
await initializeLocationService(navKeyFromMainApp,
apiKey: MixedConstants.API_KEY!,
mapKey: MixedConstants.MAP_KEY!,
isEventInUse: true);
}
/// To have eta in events
AtLocationFlutterPlugin(
const [],
calculateETA: true,
);
AtEventNotificationListener().init(navKeyFromMainApp, rootDomain);
EventKeyStreamService().init(streamAlternative: streamAlternative);
}