postFile static method

Future<Map<String, dynamic>?> postFile(
  1. String url,
  2. File file
)

直传文件

Implementation

static Future<Map<String,dynamic>?> postFile(String url, File file) async {
  try {
    assetDio();
    var result = await _dio!.post(
      url,
      data: MultipartFile.fromFile(file.path),
    );
    return result.isSuccessful ? result.data : null;
  } on DioException catch (e) {
    return _convertException(e, url);
  } on SocketException catch (e) {
    return _convertException(e, url);
  }
}