@@ -8,6 +8,7 @@ import 'dart:typed_data';
88
99import 'src/client.dart' ;
1010import 'src/exception.dart' ;
11+ import 'src/progress.dart' ;
1112import 'src/request.dart' ;
1213import 'src/response.dart' ;
1314import 'src/streamed_request.dart' ;
@@ -20,6 +21,7 @@ export 'src/client.dart';
2021export 'src/exception.dart' ;
2122export 'src/multipart_file.dart' ;
2223export 'src/multipart_request.dart' ;
24+ export 'src/progress.dart' ;
2325export 'src/request.dart' ;
2426export 'src/response.dart' ;
2527export 'src/streamed_request.dart' ;
@@ -61,12 +63,25 @@ Future<Response> get(Uri url, {Map<String, String>? headers}) =>
6163///
6264/// [encoding] defaults to [utf8] .
6365///
66+ /// If [onSendProgress] is provided it will be called to indicate
67+ /// the upload progress
68+ ///
6469/// For more fine-grained control over the request, use [Request] or
6570/// [StreamedRequest] instead.
66- Future <Response > post (Uri url,
67- {Map <String , String >? headers, Object ? body, Encoding ? encoding}) =>
68- _withClient ((client) =>
69- client.post (url, headers: headers, body: body, encoding: encoding));
71+ Future <Response > post (
72+ Uri url, {
73+ Map <String , String >? headers,
74+ Object ? body,
75+ Encoding ? encoding,
76+ Progress ? onSendProgress,
77+ }) =>
78+ _withClient ((client) => client.post (
79+ url,
80+ headers: headers,
81+ body: body,
82+ encoding: encoding,
83+ onSendProgress: onSendProgress,
84+ ));
7085
7186/// Sends an HTTP PUT request with the given headers and body to the given URL.
7287///
@@ -84,12 +99,25 @@ Future<Response> post(Uri url,
8499///
85100/// [encoding] defaults to [utf8] .
86101///
102+ /// If [onSendProgress] is provided it will be called to indicate
103+ /// the upload progress
104+ ///
87105/// For more fine-grained control over the request, use [Request] or
88106/// [StreamedRequest] instead.
89- Future <Response > put (Uri url,
90- {Map <String , String >? headers, Object ? body, Encoding ? encoding}) =>
91- _withClient ((client) =>
92- client.put (url, headers: headers, body: body, encoding: encoding));
107+ Future <Response > put (
108+ Uri url, {
109+ Map <String , String >? headers,
110+ Object ? body,
111+ Encoding ? encoding,
112+ Progress ? onSendProgress,
113+ }) =>
114+ _withClient ((client) => client.put (
115+ url,
116+ headers: headers,
117+ body: body,
118+ encoding: encoding,
119+ onSendProgress: onSendProgress,
120+ ));
93121
94122/// Sends an HTTP PATCH request with the given headers and body to the given
95123/// URL.
@@ -108,24 +136,50 @@ Future<Response> put(Uri url,
108136///
109137/// [encoding] defaults to [utf8] .
110138///
139+ /// If [onSendProgress] is provided it will be called to indicate
140+ /// the upload progress
141+ ///
111142/// For more fine-grained control over the request, use [Request] or
112143/// [StreamedRequest] instead.
113- Future <Response > patch (Uri url,
114- {Map <String , String >? headers, Object ? body, Encoding ? encoding}) =>
115- _withClient ((client) =>
116- client.patch (url, headers: headers, body: body, encoding: encoding));
144+ Future <Response > patch (
145+ Uri url, {
146+ Map <String , String >? headers,
147+ Object ? body,
148+ Encoding ? encoding,
149+ Progress ? onSendProgress,
150+ }) =>
151+ _withClient ((client) => client.patch (
152+ url,
153+ headers: headers,
154+ body: body,
155+ encoding: encoding,
156+ onSendProgress: onSendProgress,
157+ ));
117158
118159/// Sends an HTTP DELETE request with the given headers to the given URL.
119160///
120161/// This automatically initializes a new [Client] and closes that client once
121162/// the request is complete. If you're planning on making multiple requests to
122163/// the same server, you should use a single [Client] for all of those requests.
123164///
165+ /// If [onSendProgress] is provided it will be called to indicate
166+ /// the upload progress
167+ ///
124168/// For more fine-grained control over the request, use [Request] instead.
125- Future <Response > delete (Uri url,
126- {Map <String , String >? headers, Object ? body, Encoding ? encoding}) =>
127- _withClient ((client) =>
128- client.delete (url, headers: headers, body: body, encoding: encoding));
169+ Future <Response > delete (
170+ Uri url, {
171+ Map <String , String >? headers,
172+ Object ? body,
173+ Encoding ? encoding,
174+ Progress ? onSendProgress,
175+ }) =>
176+ _withClient ((client) => client.delete (
177+ url,
178+ headers: headers,
179+ body: body,
180+ encoding: encoding,
181+ onSendProgress: onSendProgress,
182+ ));
129183
130184/// Sends an HTTP GET request with the given headers to the given URL and
131185/// returns a Future that completes to the body of the response as a [String] .
0 commit comments