onInit method
Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.
Implementation
@override
void onInit() async {
super.onInit();
AppConfig.logger.t("Maps Controller Init");
// On web, ALWAYS fetch Google API key from Cloud Functions (even if
// getConfig failed — the key is never in client-side properties).
if (CloudProperties.isSecureMode || kIsWeb) {
_googleApiKey = await CloudProperties.getSecretFromCloud('googleApiKey');
} else {
_googleApiKey = CloudProperties.getGoogleApiKey();
}
profile = userServiceImpl.profile;
referencePosition = await platformGetCurrentPositionHighAccuracy();
if(profile.position != null) {
referencePosition = profile.position!;
} else {
referencePosition = await platformGetCurrentPositionHighAccuracy();
profile.position = referencePosition;
userServiceImpl.profile = profile;
}
if(referencePosition != null) {
_placePosition.value = referencePosition!;
location = Location(
latitude: referencePosition!.latitude,
longitude: referencePosition!.longitude);
}
await goToHomePosition();
}