-1

I am trying to upload user information (imagePath, firstName, lastName) to a server with the help of a http request.

Future<UserModel> userSignUp({
    String firstName,
    String lastName,
    File imagePath,
  }) async {
    Map<String, dynamic> data = {
      "FNAME": firstName,
      "LNAME": lastName,
      "image": imagePath
    };
    var response = await _helper.post(
      Services.userSignUp,
      isSecure: false,
      headers: {
        "Content-Type": "application/json",
      },
      body: json.encode(data),
    );
    return UserModel.fromJson(response);
  }
magicleon94
  • 4,887
  • 2
  • 24
  • 53
dhruvin prajapati
  • 184
  • 1
  • 3
  • 15

1 Answers1

0

I believe you're looking for a MultipartRequest, which is usually what's needed when uploading images or files to a server.

I'm assuming you're using the http package, so I think that you can find an example on how to perform this kind of request here in the MultipartRequest documentation.

magicleon94
  • 4,887
  • 2
  • 24
  • 53