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