Setting custom class fields as required

Hello, I’m currently going through the Custom class approach part of the Flutter SDK. I’ve been following the documentation and have the following code in my person.dart file:

import 'package:backendless_sdk/backendless_sdk.dart';

@reflector
class Person {
  late String name;
  late int? age = 10;
  DateTime? created;
  DateTime? updated;
  String? objectId;
  
  Person();
}

I run flutter packages pub run build_runner build regularly as I make changes, but want to set the name field to be required, because when I get all the people from the person table, I need for them to all have names, and setting that field as required seems the best way to go about ensuring that criteria is met. Also, the reason I’ve had to add late to name and age is because otherwise I got the following error:

Non-nullable instance field 'name' must be initialized.
Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'.

I hope you can point me in the right direction!

Thanks in advance,
Ilayda

hello @Ilayda_B

Use not null constraint for column name

Also, all users should create public topics, the exception is only for paid PRO and Manage customers, so I have changed the topic public type

Hi Sergey,

Firstly I apologise for putting this in the wrong place, I was following the instructions pinned to the channel but missed that that was for paying members. Nonetheless, thank you for getting back to me so quickly! I’ll change the settings on my db now.

Best,

Ilayda