Created
December 12, 2018 15:48
-
-
Save nhancv/2eeba0546788927a762a8337de28265e to your computer and use it in GitHub Desktop.
Flutter api using http
This file contains hidden or 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 'package:http/http.dart' as http; | |
| import 'package:bflutter_poc/global.dart'; | |
| class Api { | |
| static final Api _instance = Api._private(); | |
| Api._private(); | |
| factory Api() => _instance; | |
| final String apiBaseUrl = Global().env.apiBaseUrl; | |
| Future<http.Response> searchUsers(String query) { | |
| String url = '$apiBaseUrl/search/users?q=$query'; | |
| return http.get(url); | |
| } | |
| Future<http.Response> getUserInfo(String username) { | |
| return http.get('$apiBaseUrl/users/$username'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment