setList<T> method Null safety

List<T>? setList<T>(
  1. String name,
  2. List<T> value
)

Sets the provided T value to the SchemaDocument for the given name of the field as a List. Returns true if the field was found and set, false otherwise. If the field does not exist, it will be created.

final doc = SchemaDocument();
final res = doc.setList<String>('names', ['John Doe', 'Jane Doe']); // sets the value of the field 'names' to ['John Doe', 'Jane Doe']

Implementation

List<T>? setList<T>(String name, List<T> value) {
  final field = fields.firstWhereOrNull((e) => e.name == name);
  if (field == null) {
    return null;
  }
  return field.setList<T>(value);
}