Created
October 3, 2017 11:13
-
-
Save sergiandreplace/c45814964ab6607f049a40ff7c276fb6 to your computer and use it in GitHub Desktop.
Api request on dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:convert'; | |
import 'package:flutter/services.dart'; | |
class SWApi { | |
Future<Map<String, String>> getCharacter(String id) async { | |
var httpClient = createHttpClient(); | |
var response = await httpClient.get('https://swapi.co/api/people/${id}/'); | |
Map<String, Object> character = JSON.decode(response.body); | |
print(character); | |
return character; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment