put static method
Sends an HTTP PUT request with the given headers and body to the given URL.
body
sets the body of the request. It can be a String, a List or a Map<String, String>. If it's a String, it's encoded using encoding
and used as the body of the request. The content-type of the request will default to "text/plain".
If body
is a List, it's used as a list of bytes for the body of the request.
If body
is a Map, it's encoded as form fields using encoding
. The content-type of the request will be set to "application/x-www-form-urlencoded"; this cannot be overridden.
encoding
defaults to utf8.
指定されたヘッダーと本文を含む HTTP PUT 要求を指定された URL に送信します。
body
リクエストの本文を設定します。 String、List、または Map<String, String> のいずれかです。文字列の場合は、encoding
を使用してエンコードされ、リクエストの本文として使用されます。リクエストの content-type は、デフォルトで「text/plain」になります。
body
がリストの場合、リクエストの本文のバイトのリストとして使用されます。
body
が Map の場合、encoding
を使用してフォーム フィールドとしてエンコードされます。リクエストのコンテンツ タイプは「application/x-www-form-urlencoded」に設定されます。これはオーバーライドできません。
encoding
のデフォルトは utf8 です。
Implementation
static Future<ApiResponse> put(
String path, {
Map<String, String>? headers,
Object? body,
Encoding? encoding,
}) async {
final url = Uri.parse(path);
return http.put(
url,
headers: headers,
body: body,
encoding: encoding,
);
}