set<T> method Null safety

bool set<T>(
  1. String name,
  2. T value
)

Sets the provided T value to the SchemaDocument for the given name of the field. Returns true if the field was found and set, false otherwise.

Example

final doc = SchemaDocument();
final res = doc.set<String>('name', 'John Doe'); // sets the value of the field 'name' to 'John Doe'

Implementation

bool set<T>(String name, T value) {
  final field = fields.firstWhereOrNull((e) => e.name == name);
  if (field == null) {
    return false;
  }
  return field.setValue(value) != null;
}