Error adding Relation with Flutter

I’m trying to follow this tutorial How to Build a Social App Backend With Backendless (Part 2) | MBaaS with Flutter SDK but I have an error adding the relationship.

I have a table Tours with one field “likes” of type DATA OBJECT RELATIONSHIP 1 to Many to table Users

I’m using this code extracted from flutter documentation to add the relation:

Backendless.data.mapTableToClass(“Tours”, Tour);
return Backendless.data
.withClass()
.addRelation(tour, “likes”, children: [currentUser]).then((response) {
// related object has been added
print(response.toString());
});

But I get an error:

Exception has occurred.
PlatformException (PlatformException(, No required arguments, null))

I have tried to pass only the currentUser.ojectId, not the full object, but I get the same error:
return Backendless.data
.withClass()
.addRelation(tour, “likes”, children: [currentUser.getObjectId]).then((response) {
// related object has been added
print(response.toString());
});

My AppID is EF16A871-80DD-437B-FF13-FAF3968E1D00

Regards,
Dani

Hi @Dani_Sevilla

We are looking at this issue and answer you as soon as possible.

Best regards,
Yevgen.

Hi @Yevgen_Baz,

I see a strange thing in relation field that I have created.

The field is “likes” of type DATA OBJECT RELATIONSHIP 1 to Many to table Users as you can see:

But if I edit this field the showed related table is Device Registration:

I have deleted the field and created a new field and I have the same strange effect…

About wrong table name in editor preview:

  • it’s only editor preview issue and doesn’t have impact on relations functionality.
  • there was added internal ticket BKNDLSS-21065 to fix it.
    We’ll update you when fix released.

Best regards,
Yevgen

Hi @Yevgen_Baz,

Ok, I understand the problem with the table name…

You will continue investigating the problem with the AddRelation in the Flutter SDK or the open ticket is about this problem?

Hi @Dani_Sevilla
Sure, we’re investigating the AddRelation in the Flutter SDK.

Best regards, Yevgen

Hi @Dani_Sevilla

I couldn’t reproduce your issue with addRelation method. Your code sample runs fine for me. Can you please specify what OS do you run the app on? Please also make sure the tour and currentUser variables are NOT null. And don’t forget to run the command

flutter packages pub run build_runner build

after custom class declaration.

Best Regards,
Maksym

Hi @Maksym_Khobotin

Here you have attached a minimal example Application with the same error:

The App ID for this example is EE93A317-9965-49A1-FF06-BEB3F3B8F000
I’m testing the App in IOS simulator and IOS device and I have the same error.
I’m using backendless_sdk: ^1.1.4 version

I reproduced the issue on iOS device and created the internal ticket BKNDLSS-21071.

I will update you on the progress.

Best Regards,
Maksym

Hi @Dani_Sevilla

We fixed the addRelation method and published Flutter SDK v.1.1.5. Also we’ve updated relations method signatures so now you can just use parent and child object IDs instead of the objects itself.

Best Regards,
Maksym

Hi @Maksym_Khobotin

Now It works, Thank you…

Good job guys!

Regards,
Dani