Start a new topic

setLocation from flutter

I am trying to adjust one of the provided samples so it uses the device's gps location. To achieve that, I have implemented a third party plugin, which is providing the necessary arguments. Yet I do not know how to exactly call the setLocation-method from within the flutter app.

I have not found a thread tackling that problem, if you have one in mind I am happy to have a look since I am sure that I am not the first to have an issue with this.

Thanks in advance!



Seems like I am still kind of stuck.

I am using the sample '09_ObtainPoiData_2_FromLocalResource' and have modified the myjsondata.js so it displays a marker exactly at my location as this:

var myJsonData = [{
"id": "1",
"longitude": "128.7347174",
"latitude": "-15.7819525",
"altitude": "100.0",
"name": "POI#1"

The objects still spawn multiple times and move with me. I expected them to stay at the given location.

Am I missing something?

Any help is much appreciated!


A reason for moving POIs can be due to the compass values that are fed to the SDK. If these are inaccurate or change the POIs move with it. Please make sure to test also outside and not near metal to see if this improves the behavior.



Hi Nicola,

that did not exactly help. Just to be clear, the POIs are not moving left to right, but with me while I am moving (far off metal).

Do I have to provide other information to the SDK than the one given via .setLocation(...)?


 Furthermore the message "Trying to find out where you are" keeps showing up, though the third party plugin doesn't seem to have any problems locating the device.


The message 'Trying to find out where you are' indicates that you don't have a GPS fix yet. As long as this message is shown, we can't distinguish where you are and can't display the POIs. If the messages comes and goes, this indicates that the signal is not stable.

For the compass issue. Can you please try with the device and a compass app to see how the compass is behaving in the location you're testing. If the values move there as well this is another indication that the compass values are not as accurate as needed.

Thx and greetings


The message 'Trying to find out...' is shown constantly, while other apps with GPS work fine. 

Same for the compass, other apps don't seem to have a problem.

Can I provide you with some other information that might help finding the error?

I think I have misunderstood the Location Provider section profoundly.

I thought I'd only have to pass the gps data into


which I did with help of the flutter plugin 'location'.

Is it correct that I have to implement this Location Strategy somewhere in my flutter app?



So this message is shown in the unchanged SDK sample app? Or did you change something? If you changed something, please also have a look at the unchanged sample app.

Do you get a GPS position on this device if you try a GPS status app?

Thx and greetings


Hi Hendrik,

You can find details on Flutter Location handling here:

I hope this helps. Greetings


 When you say SDK sample app, do you mean e. g. the sample '09_ObtainPoiData_2_FromLocalResource'? Yes, that is unchanged.

If you mean the actual flutter code, here is it:

import 'package:flutter/material.dart';
import 'package:augmented_reality_plugin_wikitude/architect_widget.dart';
import 'package:augmented_reality_plugin_wikitude/startupConfiguration.dart';

import 'package:location/location.dart';

class Ar extends StatefulWidget {
_ArState createState() => _ArState();

class _ArState extends State<Ar> with WidgetsBindingObserver {
ArchitectWidget architectWidget;

String _licenseKey =

StartupConfiguration startupConfiguration = StartupConfiguration(
cameraPosition: CameraPosition.BACK,
cameraFocusMode: CameraFocusMode.CONTINUOUS,
cameraResolution: CameraResolution.AUTO);

Widget build(BuildContext context) {
return Scaffold(appBar: AppBar(), body: Container(child: architectWidget));

void initState() {

architectWidget = new ArchitectWidget(
onArchitectWidgetCreated: onArchitectWidgetCreated,
licenseKey: _licenseKey,
startupConfiguration: startupConfiguration,
features: [
], //image_tracking, object_tracking, geo or/and instant_tracking


void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
case AppLifecycleState.paused:
if (this.architectWidget != null) {
case AppLifecycleState.resumed:
if (this.architectWidget != null) {


void dispose() {
if (this.architectWidget != null) {

Future<void> onArchitectWidgetCreated() async {

Future<void> onLoadSuccess() async {

Future<void> onLoadFailed(String error) async {

void _setupLocation() async {
var location = new Location();

location.onLocationChanged().listen((LocationData loca) {

100, //also tried with loca.altitude
0); //also tried with loca.accuracy

Thanks in advance!

That does not seem suitable as I would have to use a deprecated Flutter SDK:

Because wikitude depends on background_location_updates >=0.0.2
which requires SDK version >=1.19.0 <2.0.0, version solving failed.

Do you see this being updated in the near future?

Do you have any possible alternatives in mind?


just an update:

It kind of works with the plugin location 2.3.5 (I can go past a POI, but it is not scaling yet as I am moving further away), though I am still told that the SDK is trying to find me.

The accuracy is down to 5 metres.

Hi Hendrik,

Thx for your feedback and the accuracy. It sounds to me that you solved the problem with the plugin version. For the scaling: did you go just some meters or further. The scaling would only show for POIs that are further away.

Thx and greetings


Login or Signup to post a comment