Fix #104 Support for setting HTTP headers

This commit is contained in:
Collin Jackson
2015-11-16 14:00:07 -08:00
parent d5e71f768b
commit e3b9094f2a
3 changed files with 36 additions and 20 deletions

View File

@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'package:flutter/http.dart' as http;
import 'package:flutter/material.dart';
@@ -30,14 +32,17 @@ class PostDemoState extends State<PostDemo> {
super.initState();
}
void _refresh() {
Future _refresh() async {
setState(() {
_response = null;
});
http.post("http://httpbin.org/post", body: "asdf=42").then((http.Response response) {
setState(() {
_response = response.body;
});
http.Response response = await http.post(
"http://httpbin.org/post",
body: "asdf=42",
headers: { "foo": "bar" }
);
setState(() {
_response = response.body;
});
}