Updating User Password - Flutter SDK

I’m trying to help users change their password after they have forgotten it and received a provisional password like wMjKyu67A

After they log in with the provisional password, I want them to be able to register a new one through a TextField and log them in right away or maybe take them to the Login Page. IDK yet. The point is, for this I have to update the password property in the ‘Users’ table through the API with the value typed.

I have tried with several Recipes, documentation from other SDKs, the Flutter SDKs git and Topics from this forum but havent been able.

This dude Cannot update user password is talking about a setPassword() method which isnt found in the Flutter SDK:

My Attempts:

Attempt 1:

//Sets new password and logs him in (takes him to the Home() page)

              print("Updating user object without login.");

              String id= user.getObjectId();
              String pass=user.password;

              print("My id is $id");
              print("My Password is $pass");

              user.setProperty("objectId", "$id");
              user.setProperty("password", "jaja");
              Backendless.userService.update(user).then((user) {
                print("User has been updated");
                print("Password - ${user.getProperty("password")}");

Attempt 2:

String correo=user.email;
print("El usuario tiene email: $correo");
user.password = "$newPassword";
    .then((response) {
      builder: (context) => Home(index: 1),
});.catchError((error) {
  handleReestablecerPass(context, error);

Finally, what can you tell me about this?

I see setPassword() here but its not recognized by the IDE

Hi, Samuel!

The best way to update password for user i to use Backendless.userService.update func.
After getting BackendlessUser object you can set new password in two ways:

  1. user.setProperty("password", "your_new_password");
  2. user.password = "your_new_password";

The second approach in fact is calling setter for password property. You shouldn’t confuse it with calling setPassword() method. In this case it looks like just setting the property directly.
You can read more in language tour: https://dart.dev/guides/language/language-tour#getters-and-setters

But I’ve found the bug with Backendless.userService.update on iOS. It will be fixed in the next release of BackendlessSwift, which is the dependency of Flutter-SDK.

As a workaround you’re able to use this code:

final user = await Backendless.userService.login("email@email.com", "temp_password");
Map<dynamic, dynamic> entity = {"objectId": user.getObjectId(), "password": "new_password"};
final savedEntity = await Backendless.data.of("Users").save(entity);
print("Check saved entity: $saved");

// Do this to check, that password was saved correctly
await Backendless.userService.logout();
final userWithUpdatedPass = await Backendless.userService.login("email@email.com", "new_password");
print("Did login with new password");


For me the only way it works is with the workaround for both IOS and Android.

Thanks a lot, though, I had been struggling with this.