setList<T> method

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.key == name);
  if (field == null) {
    throw Exception('Field not found');
  }
  return field.setList<T>(value);
}