getList<T> method

List<T>? getList<T>()

Checks if the SchemaDocumentValue is of the provided T type. If the value cannot be cast to the provided type, or the provided T doesnt match Kind, then false is returned.

final doc = SchemaDocument();
final names = doc.getList<String>('name'); // returns true if the field 'name' is a list of strings

Implementation

List<T>? getList<T>() {
  if (kind != Kind.LIST) {
    return null;
  }
  final list = <T>[];
  for (final val in listValue.value) {
    final v = val.getValue<T>();
    if (v != null) {
      list.add(v);
    }
  }
  return list;
}