initializeLocationService function
void
initializeLocationService(})
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.
showDialogBox
if false dialog box wont be shown.
streamAlternative
a function which will return updated lists of KeyLocationModel
Implementation
void initializeLocationService(AtClientImpl atClientImpl, String currentAtSign,
GlobalKey<NavigatorState> navKey,
{required String mapKey,
required String apiKey,
bool showDialogBox = false,
String rootDomain = MixedConstants.ROOT_DOMAIN,
Function? getAtValue,
Function(List<KeyLocationModel>)? streamAlternative}) async {
/// initialise keys
MixedConstants.setApiKey(apiKey);
MixedConstants.setMapKey(mapKey);
try {
/// So that we have the permission status beforehand & later we dont get
/// PlatformException(PermissionHandler.PermissionManager) => Multiple Permissions exception
await Geolocator.requestPermission();
} catch (e) {
print('Error in initializeLocationService $e');
}
AtLocationNotificationListener().init(
atClientImpl, currentAtSign, navKey, rootDomain, showDialogBox,
newGetAtValueFromMainApp: getAtValue);
KeyStreamService().init(AtLocationNotificationListener().atClientInstance,
streamAlternative: streamAlternative);
}