iPhone simulator crashes on saving data to backendless

Hey all, I do have an issue I can’t solve by myself. I’m using VS Code together with Flutter and Backendless on a Mac.

My specs

  • sdk: “>=2.12.1 <3.0.0”
  • backendless_sdk: ^7.0.0
  • build_runner: ^2.1.1
  • latest backendless
  • using reflector api and set up correctly

What I try to do
Simply saving a new object to database of backendless with flutter

Habit entity

import 'package:backendless_sdk/backendless_sdk.dart';

@reflector
class Habit {
  bool? pinned;
  String? description;
  Object? icon;
  String? title;
  DateTime? updated;
  DateTime? created;
  BackendlessUser? user;
}

business code to save it

Habit createdHabit = Habit();
  createdHabit
    ..description = descriptionController?.text
    ..icon = {
      'codePoint': _icon?.icon?.codePoint,
      'fontFamily': _icon?.icon?.fontFamily,
      'fontPackage': _icon?.icon?.fontPackage,
    }
    ..pinned = false
    ..title = nameController?.text
    ..user = _currentUser;

Backendless.data.withClass<Habit>().save(createdHabit);

What happens
iPhone simulator crashes and exits with message

Lost connection to device.
Exited (sigterm)

Issue is, there is no exception thrown, so I don’t really know where the problem is.

Thanks in advance
Lennart

Try adding a try catch block and log the error if any.

2 Likes

Also, what are you trying to accomplish with this property in the Habit class:

BackendlessUser? user

The connection of the entry with the user. Is this not necessary? I already wondered about the ownerId and if it’s enough anyway.

The “save” call will not save any relations anyway, so that assignment is not necessary.

1 Like

Tried using a try catch around it. Nothing shown. Crashes.

But I found out what it is. It’s because of

..user = _currentUser;

I removed it and also from object definition and now it works. But would be great to see any exception thrown because of that.

A crash usually occurs when there is an unhandled exception.

Yea but wouldn’t have a try catch block do something?

It would if it is wide enough