Skip to content

Connection problem to backend #8

Answered by ikhsan3adi
aksebzeci asked this question in Q&A
Discussion options

You must be logged in to vote

I have fixed the type casting error on the register page

@override
  Future<void> register(User user, String password) async {
    FormData formData = FormData();

    if (user.profileImageUrl != null) {
      formData.files.add(MapEntry(
        "profile_image",
        await MultipartFile.fromFile(user.profileImageUrl!, filename: user.profileImageUrl!.split('/').last),
      ));
    }

    // i added this line
    Map<String, dynamic> newUser = user.toJson().map((key, value) => MapEntry(key, value ?? 'null'));

    formData.fields.addAll(newUser.cast<String, String>().entries);
    formData.fields.add(MapEntry('password', password));

    await _dio.post(
      '/users',
      data: for…

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@ikhsan3adi
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ikhsan3adi
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants