Last active
December 17, 2019 16:43
-
-
Save r3dm1ke/3f8e366c3e6fb6f464281655ada2a49a to your computer and use it in GitHub Desktop.
Sending POST requests in Dart/Flutter
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; | |
| // Sending a POST request | |
| const url = 'https://some-api.com/users'; | |
| const payload = {online: false}; | |
| const response = await http.post(url, body: payload); | |
| print(response.statusCode); // 200 | |
| // Sending a POST request with headers | |
| const headers = {'Content-Type': 'application/json'}; | |
| const response_1 = await http.post(url, headers: headers, body: payload); | |
| print(response_1.statusCode); // 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment