postForm static method

Future<Map<String, dynamic>?> postForm(
  1. String url, {
  2. Map<String, dynamic>? params,
  3. ProgressCallback? onSendProgress,
})

post请求,form编码 如需上传文件,则传入MultipartFile类型,如:

Implementation

static Future<Map<String,dynamic>?> postForm(
  String url,
  { Map<String, dynamic>? params,
  ProgressCallback? onSendProgress,
}) async {
  try {
    var result = (await _dio!.post(
      url,
      data: params!=null ? FormData.fromMap(params) : null,
      onSendProgress: onSendProgress,
    ));
    return result.isSuccessful ? (result.data ?? {}) : null;
  } on DioException catch (e) {
    return _convertException(e, url, params: params);
  } on SocketException catch (e) {
    return _convertException(e, url, params: params);
  }
}