Start a new topic

How to access a json file from local filesystem

I have setup a flutter application where I create some local files with the POI data that Wikitude should use.

How I could point the javascript file to access those files (both for Android and iOS)?

Is there a way to pass the data from flutter dart?


Thank you.


Hi Aitor,


I didn't clearly understood your reply at first.

Now after reading it for second time I understood what you have written and I can verify that it works as it supposed to.

All poiData is being parsed from the local file that I have created in application document folder with Flutter.

Hi Aitor,

this is how I have already implemented, but I need to read the data once the app launch and then to have an option from the settings to reload the data.

But this data is saved on the document folder (regardless the system) and I would like to read the data from Wikitude.

If you have a look at our sample app: https://github.com/Wikitude/wikitude-flutter-plugin-examples our 09_ObtainPoiData_2_FromLocalResource shows how to load the JSON file. As summary, you will have to read the JSON file as a list of pois (which is already create in our sample app) and send it to the javascript with the next line: this.architectWidget.callJavascript("World.loadPoisFromJsonData(" + jsonEncode(pois) + ");");.


Regards,


Aitor.

Hi Aitor,

The file is saved on the document folder of the device and it's been updated every time the application starts.

How it will be saved on the assets folder and then the application work natively on both android and iOS.

Unfortunately you need to have the assets files in the same folder level than the JS file. If your HTML/JS/CSS files are located in the assets folder, what you could do is to copy those files into the same folder than your POI data. Once that is done, the path set in the JS file should be a relative path.


Regards,


Aitor.

Login or Signup to post a comment