PropertyPlaceholderHelper class

A utility class for resolving string values that contain placeholders in the format #{name}.

The placeholder values can be substituted using either a Map<String, String> or a custom PlaceholderResolverFn.

Example

final helper = PropertyPlaceholderHelper('\#{', '}');
final result = helper.replacePlaceholders('Hello \#{name}!', {'name': 'World'});
print(result); // Output: Hello World!

You can also provide default values or escape characters using the PropertyPlaceholderHelper.more constructor.

Advanced Example

final helper = PropertyPlaceholderHelper.more('\#{', '}', ':', r'\', false);
final result = helper.replacePlaceholders('Welcome \#{user:Guest}', {});
print(result); // Output: Welcome Guest

Constructors

PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix)
A utility class for resolving string values that contain placeholders in the format #{name}.
PropertyPlaceholderHelper.more(String placeholderPrefix, String placeholderSuffix, String? valueSeparator, Character? escapeCharacter, bool ignoreUnresolvablePlaceholders)
A utility class for resolving string values that contain placeholders in the format #{name}.

Properties

hashCode int
The hash code for this object.
no setterinherited
parser PlaceholderParser
The internal parser that handles placeholder resolution logic.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parseStringValue(String value, PlaceholderResolverFn placeholderResolver) String
replacePlaceholders(String value, Map<String, String> properties) String
Replaces all #{name}-style placeholders in value using the given properties map.
replacePlaceholdersWithResolver(String value, PlaceholderResolverFn placeholderResolver) String
Replaces all #{name}-style placeholders in value using a placeholderResolver.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited