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