blob: 449f7753fb7d9ffadd0c19246714124e56e6b532 [file] [log] [blame] [view]
# property method
*[<Null safety>](https://dart.dev/null-safety)*
[PropertyMatcher](../../package-fuchsia_inspect_testing/PropertyMatcher-class.md) property
(String name)
<p>Get a PropertyMatcher for a property on this node.</p>
<p>If the property cannot be found or is not a value type, an invalid
PropertyMatcher is returned.</p>
## Implementation
```dart
PropertyMatcher property(String name) {
if (!_valid) {
// No error, it would have been added creating the node itself.
return PropertyMatcher._invalid(_parent);
}
int valueIndex = _parent._findNamedValue(name, _index);
if (valueIndex == 0) {
_parent._addError('Cannot find property $name');
return PropertyMatcher._invalid(_parent);
} else if ([
BlockType.nodeValue,
BlockType.tombstone,
BlockType.nameUtf8,
BlockType.extent
].contains(Block.read(_parent._holder, valueIndex).type)) {
_parent._addError('Value $name found, but it is not a property type');
return PropertyMatcher._invalid(_parent);
}
return PropertyMatcher._valid(_parent, valueIndex);
}
```