Invoking a JSON service using Android Studio

The_Ogre

Honorary Master
Joined
Apr 30, 2010
Messages
27,845
Reaction score
10,969
Location
Cape Town
I'm needing help with this, please guys.

I've been trying a few things to learn, but I'm not getting things right. Does anybody have a boilerplate or a just plain step by step tut to do this?
 
In short, I have a JSON webservice I need to call, but I have no idea how. I'm specifically interested in using Flutter, but if I can just call the service from the emulator for now I'd be happy
 
1. Add the http package
Code:
dependencies:
  http: <latest_version>

2. Make a network request
Code:
Future<http.Response> fetchPhotos(http.Client client) async {
  return client.get('https://jsonplaceholder.typicode.com/photos');
}
 
Also, do a search on medium.com, some really good flutter tutorials, including on networking and json parsing.

“Build Your First App with Flutter: Fetching Data from an API” by Helio S. Junior https://link.medium.com/SaSYwDG9i0"

“Getting response from REST API in Flutter” by Fabusuyi Ayodeji https://link.medium.com/I4WPyqO9i0

Many more flutter articles and tutorials there...
 
Last edited:
Check YouTube?
No, that never works for me. I hate the idea of playing the video, pausing it and then trying it. I tried it before and its time consuming - especially because I'm unable to copy and paste the code.

For the record, I've created the database (MariaDB) and then have an application server that I've written in Go reading and writing data to and from the database. I've also written the RESTful API and now I need to learn Android and iOS. This is the reason why I want to learn Flutter, but I'm so damn impatient and was hoping I could cheat by reusing existing code and adapting it to my needs. :ROFL:

By the way all of this is running on Ubuntu running on a Raspberry Pi from an 8GB Micro SD card - this reminds me, I need to see if I can get a bigger one because space is becoming an issue.
 
Last edited:
No, that never works for me. I hate the idea of playing the video, pausing it and then trying it. I tried it before and its time consuming - especially because I'm unable to copy and paste the code..

This may sound silly, but sometimes you need to go slow in order to gain the understanding you need in order to implement something.

When I have issues like yours, I will find a video(usually a Traversy vid) and watch the entire thing and make notes. I'll have a look at the code and jot it down in pseudo code and take it from there. Then I start by scaffolding my solution out, test the solution throughout the process and then run the entire program through a debugger and make sure that it works etc.
 
Top
Sign up to the MyBroadband newsletter
X