get<T> method
Returns the provided T
value from the SchemaDocument for the given name
of the field, or null if the field does not exist.
final doc = SchemaDocument();
final property = doc.get<String>('name'); // returns the value of the field 'name' as a String
if (property != null) {
print(property); // prints the value of the field 'name'
}
throw Exception('Field not found'); // The field with the key 'name' was not found
Implementation
T? get<T>(String name) {
final field = fields.firstWhereOrNull((e) => e.key == name);
if (field == null) {
throw Exception('Field not found');
}
return field.getValue<T>();
}