SimplePlaceholderPart constructor
A PlaceholderPart that represents a basic placeholder expression with an optional fallback.
This class is used to resolve expressions like #{name}
or #{name:defaultValue}
where name
is the key to resolve, and defaultValue
is an optional fallback.
Example usage:
var part = SimplePlaceholderPart(r'#{user}', 'user', null);
var result = part.resolve(context); // resolved value or throws
The resolution process attempts the following:
- Tries to resolve the full
text()
(e.g.,#{user}
) recursively. - If unsuccessful, tries to resolve just the
key
(e.g.,user
). - If still unresolved, uses the
fallback
if provided. - Otherwise, it calls PlaceholderPartResolutionContext.handleUnresolvablePlaceholder.
This class extends PlaceholderAbstractPart, which provides shared recursive resolution logic.
Constructs a new SimplePlaceholderPart with the original text
,
key
, and optional fallback
value.
Implementation
SimplePlaceholderPart(super.text, this.key, this.fallback);