SimplePlaceholderPart constructor

SimplePlaceholderPart(
  1. String text,
  2. String key,
  3. String? fallback
)

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:

  1. Tries to resolve the full text() (e.g., #{user}) recursively.
  2. If unsuccessful, tries to resolve just the key (e.g., user).
  3. If still unresolved, uses the fallback if provided.
  4. 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);