encloseInParentheses method
Returns this string enclosed in parentheses, or null if empty.
When wrapEmpty is true, returns '()' for empty strings.
Audited: 2026-06-12 11:26 EDT
Implementation
@useResult
String? encloseInParentheses({bool wrapEmpty = false}) {
if (isEmpty) {
return wrapEmpty ? '()' : null;
}
return '($this)';
}