Want to make a network request and return a json object in Dart? To get the dynamic from inside the Future you do one of the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // option 1 async method MyAsyncMethod() async { dynamic result = await getResponse("http://google.com"); if (result is Map) { // process the data } } // option 2 callback with .then() MyNonAsyncMethod() { getResponse("http://google.com").then ( (dynamic result) { if (result is Map) { // process the data } }); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.