blob: 5d6b14411e8caff457abf42e018285ffa3b42da9 [file] [log] [blame] [view]
# stringProperty method
*[<Null safety>](https://dart.dev/null-safety)*
[StringProperty](../../package-fuchsia_inspect_inspect/StringProperty-class.md)? stringProperty
(String name)
<p>Returns a <a href="../../package-fuchsia_inspect_inspect/StringProperty-class.md">StringProperty</a> with <code>name</code> on this node.</p>
<p>If a <a href="../../package-fuchsia_inspect_inspect/StringProperty-class.md">StringProperty</a> with <code>name</code> already exists and is not deleted,
this method returns it.</p>
<p>Otherwise, it creates a new property initialized to the empty string.</p>
<p>Throws <a href="../../package-fuchsia_inspect_inspect/InspectStateError-class.md">InspectStateError</a> if a non-deleted property with <code>name</code> already
exists but it is not a <a href="../../package-fuchsia_inspect_inspect/StringProperty-class.md">StringProperty</a>.</p>
## Implementation
```dart
StringProperty? stringProperty(String name) {
if (_writer == null) {
return StringProperty.deleted();
}
if (_properties.containsKey(name)) {
if (_properties[name] is! StringProperty) {
throw InspectStateError("Can't create StringProperty named $name;"
' a different type exists.');
}
return _properties[name] as StringProperty?;
}
return _properties[name] = StringProperty._(name, this, _writer!);
}
```